archlinux.plugin.zsh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #######################################
  2. # Pacman #
  3. #######################################
  4. # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
  5. alias pacupg='sudo pacman -Syu'
  6. alias pacin='sudo pacman -S'
  7. alias paclean='sudo pacman -Sc'
  8. alias pacins='sudo pacman -U'
  9. alias paclr='sudo pacman -Scc'
  10. alias pacre='sudo pacman -R'
  11. alias pacrem='sudo pacman -Rns'
  12. alias pacrep='pacman -Si'
  13. alias pacreps='pacman -Ss'
  14. alias pacloc='pacman -Qi'
  15. alias paclocs='pacman -Qs'
  16. alias pacinsd='sudo pacman -S --asdeps'
  17. alias pacmir='sudo pacman -Syy'
  18. alias paclsorphans='sudo pacman -Qdt'
  19. alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
  20. alias pacfileupg='sudo pacman -Fy'
  21. alias pacfiles='pacman -F'
  22. alias pacls='pacman -Ql'
  23. alias pacown='pacman -Qo'
  24. alias pacupd="sudo pacman -Sy"
  25. function paclist() {
  26. pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
  27. }
  28. function pacdisowned() {
  29. local tmp_dir db fs
  30. tmp_dir=$(mktemp --directory)
  31. db=$tmp_dir/db
  32. fs=$tmp_dir/fs
  33. trap "rm -rf $tmp_dir" EXIT
  34. pacman -Qlq | sort -u > "$db"
  35. find /etc /usr ! -name lost+found \
  36. \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
  37. comm -23 "$fs" "$db"
  38. rm -rf $tmp_dir
  39. }
  40. alias pacmanallkeys='sudo pacman-key --refresh-keys'
  41. function pacmansignkeys() {
  42. local key
  43. for key in $@; do
  44. sudo pacman-key --recv-keys $key
  45. sudo pacman-key --lsign-key $key
  46. printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
  47. --no-permission-warning --command-fd 0 --edit-key $key
  48. done
  49. }
  50. if (( $+commands[xdg-open] )); then
  51. function pacweb() {
  52. if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then
  53. local underline_color="\e[${color[underline]}m"
  54. echo "$0 - open the website of an ArchLinux package"
  55. echo
  56. echo "Usage:"
  57. echo " $bold_color$0$reset_color ${underline_color}target${reset_color}"
  58. return 1
  59. fi
  60. local pkg="$1"
  61. local infos="$(LANG=C pacman -Si "$pkg")"
  62. if [[ -z "$infos" ]]; then
  63. return
  64. fi
  65. local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
  66. local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
  67. xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
  68. }
  69. fi
  70. #######################################
  71. # AUR helpers #
  72. #######################################
  73. if (( $+commands[aura] )); then
  74. alias auin='sudo aura -S'
  75. alias aurin='sudo aura -A'
  76. alias auclean='sudo aura -Sc'
  77. alias auclr='sudo aura -Scc'
  78. alias auins='sudo aura -U'
  79. alias auinsd='sudo aura -S --asdeps'
  80. alias aurinsd='sudo aura -A --asdeps'
  81. alias auloc='aura -Qi'
  82. alias aulocs='aura -Qs'
  83. alias aulst='aura -Qe'
  84. alias aumir='sudo aura -Syy'
  85. alias aurph='sudo aura -Oj'
  86. alias aure='sudo aura -R'
  87. alias aurem='sudo aura -Rns'
  88. alias aurep='aura -Si'
  89. alias aurrep='aura -Ai'
  90. alias aureps='aura -As --both'
  91. alias auras='aura -As --both'
  92. alias auupd="sudo aura -Sy"
  93. alias auupg='sudo sh -c "aura -Syu && aura -Au"'
  94. alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
  95. # extra bonus specially for aura
  96. alias auown="aura -Qqo"
  97. alias auls="aura -Qql"
  98. function auownloc() { aura -Qi $(aura -Qqo $@); }
  99. function auownls () { aura -Qql $(aura -Qqo $@); }
  100. fi
  101. if (( $+commands[pacaur] )); then
  102. alias pacclean='pacaur -Sc'
  103. alias pacclr='pacaur -Scc'
  104. alias paupg='pacaur -Syu'
  105. alias pasu='pacaur -Syu --noconfirm'
  106. alias pain='pacaur -S'
  107. alias pains='pacaur -U'
  108. alias pare='pacaur -R'
  109. alias parem='pacaur -Rns'
  110. alias parep='pacaur -Si'
  111. alias pareps='pacaur -Ss'
  112. alias paloc='pacaur -Qi'
  113. alias palocs='pacaur -Qs'
  114. alias palst='pacaur -Qe'
  115. alias paorph='pacaur -Qtd'
  116. alias painsd='pacaur -S --asdeps'
  117. alias pamir='pacaur -Syy'
  118. alias paupd="pacaur -Sy"
  119. fi
  120. if (( $+commands[trizen] )); then
  121. alias trconf='trizen -C'
  122. alias trupg='trizen -Syua'
  123. alias trsu='trizen -Syua --noconfirm'
  124. alias trin='trizen -S'
  125. alias trclean='trizen -Sc'
  126. alias trclr='trizen -Scc'
  127. alias trins='trizen -U'
  128. alias trre='trizen -R'
  129. alias trrem='trizen -Rns'
  130. alias trrep='trizen -Si'
  131. alias trreps='trizen -Ss'
  132. alias trloc='trizen -Qi'
  133. alias trlocs='trizen -Qs'
  134. alias trlst='trizen -Qe'
  135. alias trorph='trizen -Qtd'
  136. alias trinsd='trizen -S --asdeps'
  137. alias trmir='trizen -Syy'
  138. alias trupd="trizen -Sy"
  139. fi
  140. if (( $+commands[yay] )); then
  141. alias yaconf='yay -Pg'
  142. alias yaclean='yay -Sc'
  143. alias yaclr='yay -Scc'
  144. alias yaupg='yay -Syu'
  145. alias yasu='yay -Syu --noconfirm'
  146. alias yain='yay -S'
  147. alias yains='yay -U'
  148. alias yare='yay -R'
  149. alias yarem='yay -Rns'
  150. alias yarep='yay -Si'
  151. alias yareps='yay -Ss'
  152. alias yaloc='yay -Qi'
  153. alias yalocs='yay -Qs'
  154. alias yalst='yay -Qe'
  155. alias yaorph='yay -Qtd'
  156. alias yainsd='yay -S --asdeps'
  157. alias yamir='yay -Syy'
  158. alias yaupd="yay -Sy"
  159. fi
  160. # Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
  161. function upgrade() {
  162. echo ":: Checking Arch Linux PGP Keyring..."
  163. local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
  164. local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
  165. if [ $installedver != $currentver ]; then
  166. echo " Arch Linux PGP Keyring is out of date."
  167. echo " Updating before full system upgrade."
  168. sudo pacman -Sy --needed --noconfirm archlinux-keyring
  169. else
  170. echo " Arch Linux PGP Keyring is up to date."
  171. echo " Proceeding with full system upgrade."
  172. fi
  173. if (( $+commands[yay] )); then
  174. yay -Syu
  175. elif (( $+commands[trizen] )); then
  176. trizen -Syu
  177. elif (( $+commands[pacaur] )); then
  178. pacaur -Syu
  179. elif (( $+commands[aura] )); then
  180. sudo aura -Syu
  181. else
  182. sudo pacman -Syu
  183. fi
  184. }