archlinux.plugin.zsh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. alias upgrade='sudo pacman -Syu'
  26. function paclist() {
  27. # Based on https://bbs.archlinux.org/viewtopic.php?id=93683
  28. pacman -Qqe | \
  29. xargs -I '{}' \
  30. expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
  31. }
  32. function pacdisowned() {
  33. local tmp db fs
  34. tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
  35. db=$tmp/db
  36. fs=$tmp/fs
  37. mkdir "$tmp"
  38. trap 'rm -rf "$tmp"' EXIT
  39. pacman -Qlq | sort -u > "$db"
  40. find /bin /etc /lib /sbin /usr ! -name lost+found \
  41. \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
  42. comm -23 "$fs" "$db"
  43. }
  44. alias pacmanallkeys='sudo pacman-key --refresh-keys'
  45. function pacmansignkeys() {
  46. local key
  47. for key in $@; do
  48. sudo pacman-key --recv-keys $key
  49. sudo pacman-key --lsign-key $key
  50. printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
  51. --no-permission-warning --command-fd 0 --edit-key $key
  52. done
  53. }
  54. if (( $+commands[xdg-open] )); then
  55. function pacweb() {
  56. if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then
  57. local underline_color="\e[${color[underline]}m"
  58. echo "$0 - open the website of an ArchLinux package"
  59. echo
  60. echo "Usage:"
  61. echo " $bold_color$0$reset_color ${underline_color}target${reset_color}"
  62. return 1
  63. fi
  64. local pkg="$1"
  65. local infos="$(LANG=C pacman -Si "$pkg")"
  66. if [[ -z "$infos" ]]; then
  67. return
  68. fi
  69. local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
  70. local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
  71. xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
  72. }
  73. fi
  74. #######################################
  75. # AUR helpers #
  76. #######################################
  77. if (( $+commands[aura] )); then
  78. alias auin='sudo aura -S'
  79. alias aurin='sudo aura -A'
  80. alias auclean='sudo aura -Sc'
  81. alias auclr='sudo aura -Scc'
  82. alias auins='sudo aura -U'
  83. alias auinsd='sudo aura -S --asdeps'
  84. alias aurinsd='sudo aura -A --asdeps'
  85. alias auloc='aura -Qi'
  86. alias aulocs='aura -Qs'
  87. alias aulst='aura -Qe'
  88. alias aumir='sudo aura -Syy'
  89. alias aurph='sudo aura -Oj'
  90. alias aure='sudo aura -R'
  91. alias aurem='sudo aura -Rns'
  92. alias aurep='aura -Si'
  93. alias aurrep='aura -Ai'
  94. alias aureps='aura -As --both'
  95. alias auras='aura -As --both'
  96. alias auupd="sudo aura -Sy"
  97. alias auupg='sudo sh -c "aura -Syu && aura -Au"'
  98. alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
  99. alias upgrade='sudo aura -Syu'
  100. # extra bonus specially for aura
  101. alias auown="aura -Qqo"
  102. alias auls="aura -Qql"
  103. function auownloc() { aura -Qi $(aura -Qqo $@); }
  104. function auownls () { aura -Qql $(aura -Qqo $@); }
  105. fi
  106. if (( $+commands[pacaur] )); then
  107. alias pacclean='pacaur -Sc'
  108. alias pacclr='pacaur -Scc'
  109. alias paupg='pacaur -Syu'
  110. alias pasu='pacaur -Syu --noconfirm'
  111. alias pain='pacaur -S'
  112. alias pains='pacaur -U'
  113. alias pare='pacaur -R'
  114. alias parem='pacaur -Rns'
  115. alias parep='pacaur -Si'
  116. alias pareps='pacaur -Ss'
  117. alias paloc='pacaur -Qi'
  118. alias palocs='pacaur -Qs'
  119. alias palst='pacaur -Qe'
  120. alias paorph='pacaur -Qtd'
  121. alias painsd='pacaur -S --asdeps'
  122. alias pamir='pacaur -Syy'
  123. alias paupd="pacaur -Sy"
  124. alias upgrade='pacaur -Syu'
  125. fi
  126. if (( $+commands[trizen] )); then
  127. alias trconf='trizen -C'
  128. alias trupg='trizen -Syua'
  129. alias trsu='trizen -Syua --noconfirm'
  130. alias trin='trizen -S'
  131. alias trclean='trizen -Sc'
  132. alias trclr='trizen -Scc'
  133. alias trins='trizen -U'
  134. alias trre='trizen -R'
  135. alias trrem='trizen -Rns'
  136. alias trrep='trizen -Si'
  137. alias trreps='trizen -Ss'
  138. alias trloc='trizen -Qi'
  139. alias trlocs='trizen -Qs'
  140. alias trlst='trizen -Qe'
  141. alias trorph='trizen -Qtd'
  142. alias trinsd='trizen -S --asdeps'
  143. alias trmir='trizen -Syy'
  144. alias trupd="trizen -Sy"
  145. alias upgrade='trizen -Syu'
  146. fi
  147. if (( $+commands[yay] )); then
  148. alias yaconf='yay -Pg'
  149. alias yaclean='yay -Sc'
  150. alias yaclr='yay -Scc'
  151. alias yaupg='yay -Syu'
  152. alias yasu='yay -Syu --noconfirm'
  153. alias yain='yay -S'
  154. alias yains='yay -U'
  155. alias yare='yay -R'
  156. alias yarem='yay -Rns'
  157. alias yarep='yay -Si'
  158. alias yareps='yay -Ss'
  159. alias yaloc='yay -Qi'
  160. alias yalocs='yay -Qs'
  161. alias yalst='yay -Qe'
  162. alias yaorph='yay -Qtd'
  163. alias yainsd='yay -S --asdeps'
  164. alias yamir='yay -Syy'
  165. alias yaupd="yay -Sy"
  166. alias upgrade='yay -Syu'
  167. fi