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?
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 "$(brew --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 "$(brew --cellar)" -type d -maxdepth 0 | xargs ls -ltU # creation aka *installation date*
$ find "$(brew --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.
brew list
and brew ls
both are to see only the list of all installed packages.
brew ls -l
is to see the list of installed packages with date.
brew ls -lt
to see list of order by installation date.
-a
option although -l
works and will show a modified date. brew ls
also appears to be the same as brew list
, correct me if I'm wrong.
Commented
Jun 19, 2018 at 1:27
brew ls -l
worked for me, but brew ls -la
did not.
Commented
Jan 6, 2019 at 20:51
Building off @Kevin-Prichard's answer, for anybody here in 2021.
brew ls --formula -lt
brew ls --formula -ltr
brew ls --formula -t
brew ls --formula -t1
(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 to ls -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.The following code sorts packages that were manually installed (via brew install
) by the time they were last installed/upgraded/reinstalled.
Works in bash
and zsh
.
Assumes package dirpaths never contain whitespaces, and that at least one package has been installed with brew install
.
# Manually installed packages (with "brew install").
pkgs=$(brew leaves --installed-on-request)
# Birthtimes / creation times of dirs of installed packages.
btimes=()
while read -r btime; do
btimes+=( $(date -r $btime +%Y-%m-%d) )
done < <(stat -f %B $(brew --prefix $(printf %s "$pkgs")))
# Sort packages by time of last install/upgrade/reinstall.
paste -d ' ' <(printf "%s\n" "${btimes[@]}") <(printf %s "$pkgs") | sort
Sample output:
...
2022-12-06 gnu-sed
2022-12-25 bash
2022-12-25 shellcheck
2023-02-17 nano
2023-03-04 csvkit
...