archlinux.plugin.zsh 5.47 KB
Newer Older
1
2
3
#######################################
#               Pacman                #
#######################################
4

5
6
7
8
# abs and aur command check
local abs_aur=''
(( ! $+commands[abs] )) || abs_aur+=' && sudo abs'
(( ! $+commands[aur] )) || abs_aur+=' && sudo aur'
9

10

Benjamin Boudreau's avatar
Benjamin Boudreau committed
11
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
12
13
14
15
16
17
18
19
20
21
22
23
24
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
alias pacins='sudo pacman -U'
alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si'
alias pacreps='pacman -Ss'
alias pacloc='pacman -Qi'
alias paclocs='pacman -Qs'
alias pacinsd='sudo pacman -S --asdeps'
alias pacmir='sudo pacman -Syy'
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
25
alias pacfileupg='sudo pacman -Fy'
26
alias pacfiles='pacman -F'
27
28
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
29
30
alias pacupd="sudo pacman -Sy$abs_aur"
alias upgrade='sudo pacman -Syu'
Benjamin Boudreau's avatar
Benjamin Boudreau committed
31

32
function paclist() {
33
34
35
36
  # Based on https://bbs.archlinux.org/viewtopic.php?id=93683
  pacman -Qqe | \
    xargs -I '{}' \
      expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
Benjamin Boudreau's avatar
Benjamin Boudreau committed
37
}
Benjamin Boudreau's avatar
Benjamin Boudreau committed
38

39
function pacdisowned() {
40
  local tmp db fs
Benjamin Boudreau's avatar
Benjamin Boudreau committed
41
42
43
44
45
  tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
  db=$tmp/db
  fs=$tmp/fs

  mkdir "$tmp"
46
  trap 'rm -rf "$tmp"' EXIT
Benjamin Boudreau's avatar
Benjamin Boudreau committed
47
48
49

  pacman -Qlq | sort -u > "$db"

50
51
  find /bin /etc /lib /sbin /usr ! -name lost+found \
    \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
Benjamin Boudreau's avatar
Benjamin Boudreau committed
52
53
54

  comm -23 "$fs" "$db"
}
55

56
alias pacmanallkeys='sudo pacman-key --refresh-keys'
57

58
function pacmansignkeys() {
59
60
  local key
  for key in $@; do
61
62
63
64
65
66
    sudo pacman-key --recv-keys $key
    sudo pacman-key --lsign-key $key
    printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
      --no-permission-warning --command-fd 0 --edit-key $key
  done
}
67
68
69

if (( $+commands[xdg-open] )); then
  function pacweb() {
70
71
72
73
74
75
76
77
78
    if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then
      local underline_color="\e[${color[underline]}m"
      echo "$0 - open the website of an ArchLinux package"
      echo
      echo "Usage:"
      echo "    $bold_color$0$reset_color ${underline_color}target${reset_color}"
      return 1
    fi

79
80
    local pkg="$1"
    local infos="$(LANG=C pacman -Si "$pkg")"
81
82
83
    if [[ -z "$infos" ]]; then
      return
    fi
84
85
    local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
    local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
86
87
88
    xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
  }
fi
89
90
91
92
93

#######################################
#             AUR helpers             #
#######################################

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
if (( $+commands[aura] )); then
  alias auin='sudo aura -S'
  alias aurin='sudo aura -A'
  alias auins='sudo aura -U'
  alias auinsd='sudo aura -S --asdeps'
  alias aurinsd='sudo aura -A --asdeps'
  alias auloc='aura -Qi'
  alias aulocs='aura -Qs'
  alias aulst='aura -Qe'
  alias aumir='sudo aura -Syy'
  alias aurph='sudo aura -Oj'
  alias aure='sudo aura -R'
  alias aurem='sudo aura -Rns'
  alias aurep='aura -Si'
  alias aurrep='aura -Ai'
  alias aureps='aura -As --both'
  alias auras='aura -As --both'
  alias auupd="sudo aura -Sy$abs_aur"
  alias auupg='sudo sh -c "aura -Syu              && aura -Au"'
  alias ausu='sudo  sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
  alias upgrade='sudo aura -Syu'

  # extra bonus specially for aura
  alias auown="aura -Qqo"
  alias auls="aura -Qql"
  function auownloc() { aura -Qi  $(aura -Qqo $@); }
  function auownls () { aura -Qql $(aura -Qqo $@); }
fi

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
if (( $+commands[pacaur] )); then
  alias paupg='pacaur -Syu'
  alias pasu='pacaur -Syu --noconfirm'
  alias pain='pacaur -S'
  alias pains='pacaur -U'
  alias pare='pacaur -R'
  alias parem='pacaur -Rns'
  alias parep='pacaur -Si'
  alias pareps='pacaur -Ss'
  alias paloc='pacaur -Qi'
  alias palocs='pacaur -Qs'
  alias palst='pacaur -Qe'
  alias paorph='pacaur -Qtd'
  alias painsd='pacaur -S --asdeps'
  alias pamir='pacaur -Syy'
  alias paupd="pacaur -Sy$abs_aur"
  alias upgrade='pacaur -Syu'
fi

if (( $+commands[trizen] )); then
  alias trconf='trizen -C'
  alias trupg='trizen -Syua'
  alias trsu='trizen -Syua --noconfirm'
  alias trin='trizen -S'
  alias trins='trizen -U'
  alias trre='trizen -R'
  alias trrem='trizen -Rns'
  alias trrep='trizen -Si'
  alias trreps='trizen -Ss'
  alias trloc='trizen -Qi'
  alias trlocs='trizen -Qs'
  alias trlst='trizen -Qe'
  alias trorph='trizen -Qtd'
  alias trinsd='trizen -S --asdeps'
  alias trmir='trizen -Syy'
  alias trupd="trizen -Sy$abs_aur"
  alias upgrade='trizen -Syu'
fi

if (( $+commands[yaourt] )); then
  alias yaconf='yaourt -C'
  alias yaupg='yaourt -Syua'
  alias yasu='yaourt -Syua --noconfirm'
  alias yain='yaourt -S'
  alias yains='yaourt -U'
  alias yare='yaourt -R'
  alias yarem='yaourt -Rns'
  alias yarep='yaourt -Si'
  alias yareps='yaourt -Ss'
  alias yaloc='yaourt -Qi'
  alias yalocs='yaourt -Qs'
  alias yalst='yaourt -Qe'
  alias yaorph='yaourt -Qtd'
  alias yainsd='yaourt -S --asdeps'
  alias yamir='yaourt -Syy'
  alias yaupd="yaourt -Sy$abs_aur"
  alias upgrade='yaourt -Syu'
fi

if (( $+commands[yay] )); then
  alias yaconf='yay -Pg'
  alias yaupg='yay -Syu'
  alias yasu='yay -Syu --noconfirm'
  alias yain='yay -S'
  alias yains='yay -U'
  alias yare='yay -R'
  alias yarem='yay -Rns'
  alias yarep='yay -Si'
  alias yareps='yay -Ss'
  alias yaloc='yay -Qi'
  alias yalocs='yay -Qs'
  alias yalst='yay -Qe'
  alias yaorph='yay -Qtd'
  alias yainsd='yay -S --asdeps'
  alias yamir='yay -Syy'
  alias yaupd="yay -Sy$abs_aur"
  alias upgrade='yay -Syu'
fi

unset abs_aur