Created
May 19, 2023 22:50
-
-
Save nelsonaloysio/019313a217d90d9848a3d6d264bdc315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # A simple script in bash to list Arch | |
| # packages with some nifty improvements. | |
| # | |
| # usage: packages {option} | |
| # options: | |
| # installed lists user installed packages | |
| # dependencies lists dependency packages | |
| # history lists install history | |
| # removed lists uninstall history | |
| # ignored lists ignored packages | |
| # optional lists optional packages | |
| # unrequired lists unrequired packages | |
| # backup write all outputs to folder | |
| # log show pacman log | |
| function help { | |
| head -n 15 "$0" | tail -n 10 | cut -c3-; } | |
| function pacman_packages { | |
| comm -23 <(pacman -Qq | sort) <((pacman -Sl core && pacman -Sg base-devel) | cut -f2 -d' ' | sort -u); } | |
| function pacman_dependencies { | |
| pacman -Qndtq; } | |
| function pacman_history { | |
| cat /var/log/pacman.log | | |
| grep installed -w | | |
| grep 'ALPM-SCRIPTLET' -v | | |
| grep -v warning: | | |
| sed 's/].*]//;s/ installed / /;s/ (.*//;s/T.* / /;s/ .* / /;s/\[//'; } | |
| function pacman_removed { | |
| cat /var/log/pacman.log | | |
| grep removed -w | | |
| grep 'ALPM-SCRIPTLET' -v | | |
| grep -v warning: | | |
| sed 's/].*]//;s/ removed / /;s/ (.*//;s/T.* / /;s/ .* / /;s/\[//'; } | |
| function pacman_ignored { | |
| grep IgnorePkg /etc/pacman.conf -w | | |
| tail -n1 | | |
| sed 's/.*= //'; } | |
| function pacman_log { | |
| less /var/log/pacman.log; } | |
| function pacman_optional { | |
| (pacman -Qqnt && pacman -Qqntt) | | |
| sort | | |
| uniq -u; } | |
| function pacman_unrequired { | |
| comm -23 <(pacman -Qqnt | sort) <((pacman -Sl core && pacman -Sg base-devel) | cut -f2 -d' ' | sort -u); } | |
| function pacman_backup { | |
| packages > packages.txt | |
| packages-dependencies > packages-dependencies.txt | |
| packages-ignored > packages-ignored.txt | |
| packages-optional > packages-optional.txt | |
| packages-unrequired > packages-unrequired.txt | |
| pacman -Qqm > packages-AUR.txt; } | |
| case "$1" in | |
| dependencies) | |
| pacman_dependencies | |
| ;; | |
| history) | |
| pacman_history | |
| ;; | |
| removed) | |
| pacman_removed | |
| ;; | |
| ignored) | |
| pacman_ignored | |
| ;; | |
| log) | |
| pacman_log | |
| ;; | |
| optional) | |
| pacman_optional | |
| ;; | |
| unrequired) | |
| pacman_unrequired | |
| ;; | |
| backup) | |
| pacman_backup | |
| ;; | |
| help|-h) | |
| help | |
| ;; | |
| *|installed) # default | |
| pacman_packages | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment