Show installation date of packages installed with Homebrew?
Homebrew shows me all packages that I have installed with brew leaves
. However, it doesn't show me when was a package been installed.
Is it possible to make Homebrew show the installation date of packages?
Solution 1:
brew ls -lt
lists installed packages, sorted by last modified date of the package installation directory, newest to oldest.
Equivalent results can be obtained with:
find /usr/local/Cellar -type d -maxdepth 0 | xargs ls -lt
With this incantation, sort order can be changed by adding -U
(creation date) or -u
(last access date) to the ls -lt
$ find /usr/local/Cellar -type d -maxdepth 0 | xargs ls -ltU # creation aka *installation date*
$ find /usr/local/Cellar -type d -maxdepth 0 | xargs ls -ltu # last access aka last use date
Add -r
to ls -lt
to reverse order, oldest to newest.
brew ls -l
lists installed packages in alphabetical order.
It's unknown to me whether Homebrew affects a package folder's creation date during brew upgrade
, so be aware that learning the first installation date of a package may be elusive.
The -a
option for brew ls -l
appears to be no longer available.
Solution 2:
brew ls -la
this command may help you a bit. This command shows you information like command ls -la
. You may know more from here https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/ls.1.html
Solution 3:
Building off @Kevin-Prichard's answer, for anybody here in 2021.
brew ls --formula -lt
Variations
- Reverse order:
brew ls --formula -ltr
- Only print package names:
brew ls --formula -t
- Print 1 package name per line (useful for scripts):
brew ls --formula -t1
Options
(from brew ls -h
, with notes)
-
--formula
:brew
requires the--formula
flag when using-l
or-t
nowadays. Not sure when that started, but I'm on brew 3.0.1 so probably applies to versions >3.0. I'd guess this is to differentiate listing formulae vs casks (doesn't look like-lt
are supported with--cask
) -
-l
: List formulae in long-format (i.e. with "last modified" date, akin tols -l
) -
-t
: Sort formulae by time modified, listing most recently modified first. -
-r
: Reverse the order of the formulae sort to list the oldest entries first. Note: make sure to use the -t flag with this one, to reverse by last-modified. -
-1
: Force output to be one entry per line. This is the default when output is not to a terminal.
Solution 4:
Here are a few one-liner methods, and a link to a full-blown bash script. Adapt as you see fit by tinkering with the find
and awk
parameters:
List formulae updated within last day
find $(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula -type f -name "*.rb" -mtime -24h |
awk '{n=sprintf("basename %s",$0);n | getline f; close(f); sub(".rb$","",f); print f; }'
List formulae updated in last 30 minutes, with dates
find $(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula -type f -name "*.rb" -mtime -30m |
awk '{n=sprintf("basename %s",$0);n | getline f; close(f); d=sprintf("stat -f%Sm %s",$0);d | getline d; close(d); sub(".rb$","",f); print d" "f; }'
Updated in last 4 hours, with descriptions
find $(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula -type f -name "*.rb" -mtime -4h |
awk 'BEGIN {SQ="\047"; DQ="\042"} {n=sprintf("basename %s",$0);n | getline f; close(f); sub(".rb$","",f); d=sprintf("sed -En %ss/^ +desc %s(.*)%s/\\1/p%s %s",SQ,DQ,DQ,SQ,$0); d | getline d; close(d); print f": "d; }'
Bash script (output emulates brew desc
with bolded formula names)
brew-recent.sh
- Find recently updated Homebrew formulae (GitHub)
Some tips:
-
find -s
will sort output by filename - other args for time:
-mtime -90m
or-mtime -3d