X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/ca89775db49fd0376f920e77487e0485e98e787f..4c7aab190bdd467bf51a5f0503de838707830fa0:/zsh/aliases/pacman.zsh diff --git a/zsh/aliases/pacman.zsh b/zsh/aliases/pacman.zsh index 988902d..c3a71bb 100644 --- a/zsh/aliases/pacman.zsh +++ b/zsh/aliases/pacman.zsh @@ -1,9 +1,13 @@ +if (( ! $+commands[pacman] )); then + return 1 +fi + # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system. alias pacin='sudo pacman -S' # Install specific package(s) from the repositories alias pacu='sudo pacman -U' # Install specific package not from the repositories but from a file alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies -alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies +alias pacrem='sudo pacman -Rns' # Remove the specified package(s) and unneeded dependencies alias pacrm='sudo pacman -Rnsc' # Remove the specified package(s), its configuration(s) and unneeded dependencies alias pacsi='pacman -Sii' # Display information about a given package in the repositories alias pacss='pacman -Ss' # Search for package(s) in the repositories @@ -20,7 +24,31 @@ alias pacmir='sudo pacman -Syy' # Force refresh of all package li # https://bbs.archlinux.org/viewtopic.php?id=93683 paclist() { - pacman -Qei | awk 'BEGIN {FS=": "}/^Name/{printf("\033[1;36m%s\033[0m ",$2)}/^Description/{print $2}' + pacman -Qei "$@" | awk 'BEGIN {FS=": "}/^Name/{printf("\033[1;36m%s\033[0m ",$2)}/^Description/{print $2}' +} + +pacclean() { + local _pkgs=( $(pacman -Qeq) ) + for pkg in ${_pkgs[@]}; do + # the file has been removed by a previous clean + pacman -Qq $pkg 2>&1 1>/dev/null || continue + + pacman -Qi $pkg | awk 'BEGIN {FS=": "}/^Name/{printf("\n\033[1;36m%s\033[0m ",$2)}/^Description/{print $2}/^(Required|Optional For)/' + + local edrq='' + while true; do + echo -n "Explicit, Dependency, Remove, Quit? [Edrq] " + read -sk edrq + echo + case $edrq in + [Qq]) return ;; + $'\n') ;& + [Ee]) break ;; + [Rr]) sudo pacman -Rnscu $pkg; break ;; + [Dd]) sudo pacman -D --asdeps $pkg; break ;; + esac + done + done } # [l]ist [o]orphans alias paclo='pacman -Qdt' @@ -41,6 +69,11 @@ paci() { compdef '_pacman_completions_all_packages' paci=pacman pacstat() { + printf "Packages:\n" + printf "%7d native\n" $(LC_ALL=C pacman -Qn | wc -l) + printf "%7d foreign\n" $(LC_ALL=C pacman -Qm | wc -l) + printf "%7d total\n" $(LC_ALL=C pacman -Q | wc -l) + printf "Repos:\n" LC_ALL=C pacman -Sl | sed -n '/\[installed\]/s/^\([^ ]*\).*/\1/p' | uniq -c }