Open new packages homepage in homebrew - macos

Is there a way to isolate the list of new packages added to homebrew?
When I run brew upgrade it lists all the new packages,
and I want to open their homepage to see if I want to use them.
Something along the lines of
$ brew home $(brew list --new)
which iterates through all the new packages and opens their homepage...

So you can string a couple commands to do this:
List the outdated packages:
$ brew outdated
git (1.8.5.1, 1.9.0, 2.0.0 < 2.2.0)
brew home only wants the name, not the versions, so parse that out
$ brew outdated | awk '{print $1}'
git
Run brew home:
$ brew home `brew outdated | awk '{print $1}'`
OR
$ brew outdated | awk '{print $1}' | xargs brew home
Optional: My machine errors out LSOpenURLsWithRole() failed with error -1712 if I try to open more then 6 urls. Quick googling suggests that it's a timeout, which suggests that your machine and browser may time out after more or less urls.
$ for package in `brew outdated | awk '{print $1}'`; do brew home $package; done

Related

what is the meaning of pip install -v?

Recently, I seen a command of pip install -v
actually it is
$ git clone https://github.com/NVIDIA/apex
$ cd apex
$ pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
I usually command pip install something
But what is pip install -v?
-v or we can can also use --verbose. Both are same.
-v is used when you want to use or expressed something in more words than are needed.
-v Give more output. Option is additive, and can be used up to 3 times.

How to install GNU grep on Mac OS?

I need to install GNU grep on my Mac but I'm finding some difficulties.
I tried doing this:
brew install grep --with-default-names
But this is no longer an option since Homebrew removed --with-default-names.
Can anyone provide a solution for this?
Yes, --with-default-names was removed.
But some formulas, like grep, provided a workaround for this:
$ brew info grep
...
==> Caveats
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
...
First, to install, just do install without --with-default-names.
$ brew install grep
...
==> Summary
🍺 /usr/local/Cellar/grep/3.3: 21 files, 880.7KB
You should also see that same "Caveats" info I mentioned at the start. Now, by default, the Homebrew grep would be prefixed by a "g", so it's accessible as ggrep.
$ ggrep -V
ggrep (GNU grep) 3.3
Packaged by Homebrew
Copyright (C) 2018 Free Software Foundation, Inc.
...
This prevents it from shadowing the built-in grep that comes with Mac.
$ grep -V
grep (BSD grep) 2.5.1-FreeBSD
If you really need to use grep and not ggrep, just follow the instructions and put /usr/local/opt/grep/libexec/gnubin at the start of your PATH. You have to do this in your .bashrc or .bash_profile (whichever one you use).
$ echo 'export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ grep -V
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
grep (GNU grep) 3.3
Packaged by Homebrew
...

Get size of each installed formula in homebrew? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I would like to find the size of my installed brew packages so I can see how much space each is taking up. How do I go about doing this from the terminal?
Note:
some of the answers below also include brew cask packages which is also very helpful to this answer.
riffing off of PTao's solution, here's an ugly improved version which will include a human-readable sum of the combined sized of all package versions
for pkg in `brew list --formula -1 | egrep -v '\.|\.\.'`
do echo $pkg `brew info $pkg | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/\1/' | awk '{print $1;}/[0-9]$/{s+=$1};/[mM][bB]$/{s+=$1*(1024*1024);next};/[kK][bB]$/{s+=$1*1024;next} END { suffix=" KMGT"; for(i=1; s>1024 && i < length(suffix); i++) s/=1024; printf "\t(all versions: %0.1f%s)",s,substr(suffix, i, 1), $3; }'`
done
example output:
ack 173.5KB 178.4KB 182.7KB 190.5KB (all versions: 725.1K)
afl-fuzz 556.5KB 561.3KB (all versions: 1.1M)
aircrack-ng 934.2KB 953KB (all versions: 1.8M)
autoconf 1.9MB (all versions: 1.9M)
autojump 325.4KB (all versions: 325.4K)
automake 2.9MB 3.0MB 3MB (all versions: 8.9M)
bash-completion 608.6KB (all versions: 608.6K)
boost 414.6MB 398.7MB (all versions: 813.3M)
cairo 5.9MB 5.9MB (all versions: 11.8M)
cask 166.6KB (all versions: 166.6K)
cmake 31.4MB (all versions: 31.4M)
coreutils 8.5MB 7.9MB 9MB (all versions: 25.4M)
curl 3MB (all versions: 3.0M)
dos2unix 344.4KB 360.5KB (all versions: 704.9K)
ebook-tools 69.6KB 70.5KB (all versions: 140.1K)
eigen 3.5MB 6.5MB (all versions: 10.0M)
brew list --formula | xargs -n1 -P8 -I {} \
sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \
sort -h -r -k2 - | column -t
It display brews like below in sorted form (by size):
It's not exceedingly pretty, but you can do
$ brew list --formula | xargs brew info
And it will output something along the lines of
...
/usr/local/Cellar/ant/1.9.6 (1,611 files, 34.8M)
Poured from bottle on 2016-03-31 at 09:35:41
/usr/local/Cellar/ant/1.9.7 (1,611 files, 34.9M) *
Poured from bottle on 2016-12-15 at 09:58:56
..
for each package you have installed. I'm sure some wizard with grep could make this give you a nice table if you have many taps installed.
Colored list of all brew packages with size (and overall size of all versions)
for pkg in `brew list -f1 | egrep -v '\.|\.\.'`
do echo $pkg `brew info $pkg | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/\1/' | awk '{print "\033[1;32m"$1;}/[0-9]$/{s+=$1};/[mM][bB]$/{s+=$1*(1024*1024);next};/[kK][bB]$/{s+=$1*1024;next} END { suffix=" KBMBGBTB"; for(i=1; s>1024 && i < length(suffix); i+=2) s/=1024; printf "\033[0m\t(all versions: \033[33m%0.1f %s\033[0m)",s,substr(suffix, i, 2), $3; }'`
done
Output looks like this:
This shell snippet from https://gist.github.com/eguven/23d8c9fc78856bd20f65f8bcf03e691b will help you
for pkg in `brew list -f1 | egrep -v '\.|\.\.'`
do echo $pkg `brew info $pkg | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/\1/'`
done
On version Homebrew 2.7.5
Following command throw an error
brew list | xargs brew info | egrep --color '\d*\.\d*(KB|MB|GB)'
Error: Calling brew list to only list formulae is disabled! Use brew list --formula instead.
After adding --formula to brew list command it worked.
brew list --formula | xargs brew info | egrep --color '\d*\.\d*(KB|MB|GB)'

Will this bash loop apt-get install all my anaconda packages?

I don't want to just try it and mess something up.
$ dlpackages=$(ls -l anaconda3/bin | awk '{print $9}')
$ for package in $dlpackages; do sudo apt-get install $package; done
or as root: $ for package in $dlpackages; do apt-get install $package; done
Add a safety check for each package, to see if it can be located.
dlpackages=$(ls -l anaconda3/bin | awk '{print $9}')
for package in $dlpackages; do
[[ $(apt-cache search $package) ]] && sudo apt-get install $package
done
Now for every string, the install will only be executed if the package can be found.
Alternatively use the -s option of install as Eric Renouf suggested.
In general things in bin aren't the same as package names. conda list may be closer, but you'll ultimately probably have to figure out the translation of package names manually.

How do I "replay" the "Caveats" section from a homebrew recipe

When installing a homebrew recipe, you occasionally will get some useful information in the "Caveats" section that you may want to tuck under your hat. Is there any way to replay or access this information once it has been displayed at install or is it lost forever unless you copy paste somewhere?
e.g.
==> Caveats
To have launchd start mongodb at login:
ln -s /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents/
Then to load mongodb now:
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod
I might want to be able to see this again and/or know where that plist is if I want it later.
tl;dr How do I see the above snippet again after I've installed something from homebrew?
brew info mongodb will display it. If you make the changes suggested by the Caveats however, there may be other Caveats presented which will be more applicable to your actual situation.
I created a brew external command for that: https://github.com/rafaelgarrido/homebrew-caveats
$ brew caveats zsh
==> zsh: Caveats
Add the following to your zshrc to access the online help:
unalias run-help
autoload run-help
HELPDIR=/usr/local/share/zsh/helpfiles
You can also pass multiple formulas:
$ brew caveats rabbitmq mongodb
==> rabbitmq: Caveats
Management Plugin enabled by default at http://localhost:15672
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
To have launchd start rabbitmq at login:
ln -sfv /usr/local/opt/rabbitmq/*.plist ~/Library/LaunchAgents
Then to load rabbitmq now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rabbitmq.plist
Or, if you don't want/need launchctl, you can just run:
rabbitmq-server
==> mongodb: Caveats
To have launchd start mongodb at login:
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod --config /usr/local/etc/mongod.conf
Pretty handy when you need to check some configs!
To see all caveats of the currently installed formulas you can use the following command
brew info $(brew list)
You can also filter the output with awk to only get the caveats sections. (I am an awk newbie suggestions or edits are welcome)
brew info $(brew list) | awk '/^==> Caveats$/,/^[a-z][a-zA-Z0-9_+-]+: stable |^==> (Dependencies|Options)$/'
Another possibility is to use sed
brew info $(brew list) | sed '/==> Caveats/,/==>/!d;//d'
And to have a formatted output (bash)
for cmd in $(brew list); do
if brew info $cmd | grep -q Caveats; then
echo "$cmd\n";
brew info $cmd | sed '/==> Caveats/,/==>/!d;//d';
printf '%40s\n' | tr ' ' -;
fi;
done;
For those of you who have the awesome jq tool:
# For brews
$ brew info --json $(brew list) | jq -r '.[] | select(.caveats != null) | "\n\nName: \(.name)\nCaveats: \(.caveats)"'
# For casks
$ brew cask --json=v1 info $(brew cask list) | jq -r '.[] | select(.caveats != null) | "\n\nName: \(.name)\nCaveats: \(.caveats)"'
jq is a command-line JSON processor.
Updating and combining a few above anwers, here's a bash/zsh loop that can be pasted into the terminal to get all caveats for all installed brew formulae.
for x in $(brew list --formula); do
cavs=$(brew info "$x" | sed '/==> Caveats/,/==>/!d;//d')
if [ ! -z "$cavs" ]; then
echo "$x"
echo "---"
echo "$cavs"
echo ""
fi
done

Resources