archlinux.plugin.zsh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Archlinux zsh aliases and functions
  2. # Usage is also described at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
  3. # Look for yaourt, and add some useful functions if we have it.
  4. if [[ -x `which yaourt` ]]; then
  5. upgrade () {
  6. yaourt -Syu
  7. }
  8. alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
  9. # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
  10. alias yaupg='yaourt -Syua' # Synchronize with repositories before upgrading packages (AUR packages too) that are out of date on the local system.
  11. alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation
  12. alias yain='yaourt -S' # Install specific package(s) from the repositories
  13. alias yains='yaourt -U' # Install specific package not from the repositories but from a file
  14. alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
  15. alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
  16. alias yarep='yaourt -Si' # Display information about a given package in the repositories
  17. alias yareps='yaourt -Ss' # Search for package(s) in the repositories
  18. alias yaloc='yaourt -Qi' # Display information about a given package in the local database
  19. alias yalocs='yaourt -Qs' # Search for package(s) in the local database
  20. alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
  21. alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
  22. # Additional yaourt alias examples
  23. if [[ -x `which abs` ]]; then
  24. alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
  25. else
  26. alias yaupd='yaourt -Sy' # Update and refresh the local package and ABS databases against repositories
  27. fi
  28. alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package
  29. alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
  30. else
  31. upgrade() {
  32. sudo pacman -Syu
  33. }
  34. fi
  35. # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
  36. alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
  37. alias pacin='sudo pacman -S' # Install specific package(s) from the repositories
  38. alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file
  39. alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
  40. alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
  41. alias pacrep='pacman -Si' # Display information about a given package in the repositories
  42. alias pacreps='pacman -Ss' # Search for package(s) in the repositories
  43. alias pacloc='pacman -Qi' # Display information about a given package in the local database
  44. alias paclocs='pacman -Qs' # Search for package(s) in the local database
  45. # Additional pacman alias examples
  46. if [[ -x `which abs` ]]; then
  47. alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
  48. else
  49. alias pacupd='sudo pacman -Sy' # Update and refresh the local package and ABS databases against repositories
  50. fi
  51. alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package
  52. alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
  53. # https://bbs.archlinux.org/viewtopic.php?id=93683
  54. paclist() {
  55. sudo pacman -Qei $(pacman -Qu|cut -d" " -f 1)|awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}'
  56. }
  57. alias paclsorphans='sudo pacman -Qdt'
  58. alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
  59. pacdisowned() {
  60. tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
  61. db=$tmp/db
  62. fs=$tmp/fs
  63. mkdir "$tmp"
  64. trap 'rm -rf "$tmp"' EXIT
  65. pacman -Qlq | sort -u > "$db"
  66. find /bin /etc /lib /sbin /usr \
  67. ! -name lost+found \
  68. \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
  69. comm -23 "$fs" "$db"
  70. }
  71. pacmanallkeys() {
  72. # Get all keys for developers and trusted users
  73. curl https://www.archlinux.org/{developers,trustedusers}/ |
  74. awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' |
  75. xargs sudo pacman-key --recv-keys
  76. }
  77. pacmansignkeys() {
  78. for key in $*; do
  79. sudo pacman-key --recv-keys $key
  80. sudo pacman-key --lsign-key $key
  81. printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
  82. --no-permission-warning --command-fd 0 --edit-key $key
  83. done
  84. }