How do I list installed packages (by user) with a short description?
When I search for packages to install: pacman -Ss zsh
, I get following result:
extra/zsh 5.7.1-1 [installed]
A very advanced and programmable command interpreter (shell) for UNIX
I would like to get the same result using something like pacman -Qe
.
2 Answers
These work fast on my end
This will give full info of pacman -Qe results. It does pacman -Qi on each line of the pacman -Qe output
for line in "$(pacman -Qqe)"; do pacman -Qi $(echo "$line"); done
This will generate the same output as the loop you made but without doing a pacman search on each line. Uses pipes and perl to format the output of the above command
for line in "$(pacman -Qqe)"; do pacman -Qi $(echo "$line") ; done | perl -pe 's/ +/ /gm' | perl -pe 's/^(Groups +: )(.*)/$1($2)/gm' | perl -0777 -pe 's/^Name : (.*)\nVersion :(.*)\nDescription : ((?!None).*)?(?:.|\n)*?Groups :((?! \(None\)$)( )?.*)?(?:.|\n(?!Name))+/local\/$1$2$4\n $3/gm' | grep -A1 --color -P "^[^\s]+"
Same as above but didn't add "local/" to beginning of each package name
for line in "$(pacman -Qqe)"; do pacman -Qi $(echo "$line") ; done | perl -pe 's/ +/ /gm' | perl -pe 's/^(Groups +: )(.*)/$1($2)/gm' | perl -0777 -pe 's/^Name : (.*)\nVersion :(.*)\nDescription : ((?!None).*)?(?:.|\n)*?Groups :((?! \(None\)$)( )?.*)?(?:.|\n(?!Name))+/$1$2$4\n $3/gm' | grep -A1 --color -P "^[^\s]+"
This command gives the description in the same line.
expac -H M '%-20n\t%10d' $(pacman -Qe)
It is made from some commands found here in the archwiki.
pacman -Qs
gives me the desired explanation, but it cannot be combined with the-e
option. So I tried piping some outputs together using xargs and ended with a for loop:for i in `pacman -Qe | cut -d' ' -f1`; do pacman -Qs $i | grep -A1 --color "local/$i\s"; done