]> git.rmz.io Git - dotfiles.git/blob - zsh/aliases/pacman.zsh
xdg: add user-dirs.dirs
[dotfiles.git] / zsh / aliases / pacman.zsh
1 if (( ! $+commands[pacman] )); then
2 return 1
3 fi
4
5 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
6 alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
7 alias pacin='sudo pacman -S' # Install specific package(s) from the repositories
8 alias pacu='sudo pacman -U' # Install specific package not from the repositories but from a file
9 alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
10 alias pacrem='sudo pacman -Rns' # Remove the specified package(s) and unneeded dependencies
11 alias pacrm='sudo pacman -Rnsc' # Remove the specified package(s), its configuration(s) and unneeded dependencies
12 alias pacsi='pacman -Sii' # Display information about a given package in the repositories
13 alias pacss='pacman -Ss' # Search for package(s) in the repositories
14 alias pacqi='pacman -Qii' # Display information about a given package in the local database
15 alias pacqs='pacman -Qs' # Search for package(s) in the local database
16 alias pacl='pacman -Ql' # List all files owned by package(s)
17 alias paco='pacman -Qo' # List package owning the given file(s)
18 alias pacdep='sudo pacman -D --asdeps' # Mark package as dependency
19 alias pacexp='sudo pacman -D --asexplicit' # Mark package as explicit
20 alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package
21 alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
22
23 [[ -x /usr/bin/packer ]] && alias aur='packer'
24
25 # https://bbs.archlinux.org/viewtopic.php?id=93683
26 paclist() {
27 pacman -Qei "$@" | awk 'BEGIN {FS=": "}/^Name/{printf("\033[1;36m%s\033[0m ",$2)}/^Description/{print $2}'
28 }
29 # [l]ist [o]orphans
30 alias paclo='pacman -Qdt'
31 # [r]emove [o]orphans
32 alias pacro='sudo pacman -Rnscu $(pacman -Qtdq)'
33
34 # Display information about given packages (merges output of -Sii and -Qii)
35 paci() {
36 for p in $@; do
37 if [[ -n "$(pacman -Qq "$p" 2>/dev/null)" ]]; then
38 diff -u100 <(pacman -Qii "$p") <(pacman -Sii "$p" | sed '/^$/,$ d') | sed -e '1,3 d' -e 's/[-+ ]//'
39 else
40 pacman -Sii "$p"
41 fi
42 done
43 }
44 # will only work after another pacman completion has been called first
45 compdef '_pacman_completions_all_packages' paci=pacman
46
47 pacstat() {
48 printf "Packages:\n"
49 printf "%7d native\n" $(LC_ALL=C pacman -Qn | wc -l)
50 printf "%7d foreign\n" $(LC_ALL=C pacman -Qm | wc -l)
51 printf "%7d total\n" $(LC_ALL=C pacman -Q | wc -l)
52 printf "Repos:\n"
53 LC_ALL=C pacman -Sl | sed -n '/\[installed\]/s/^\([^ ]*\).*/\1/p' | uniq -c
54 }
55
56 pacdisowned() {
57 tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
58 db=$tmp/db
59 fs=$tmp/fs
60
61 mkdir "$tmp"
62 trap 'rm -rf "$tmp"' EXIT
63
64 pacman -Qlq | sort -u > "$db"
65
66 local -a d
67 if [[ -z $@ ]]; then
68 d=(/etc /usr)
69 else
70 d=($@)
71 fi
72 find ${d[@]} \
73 ! \( -name lost+found \
74 -o -path '*/local/*' \
75 -o -path "*/share/mime/*" \
76 \) \
77 \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
78
79 comm -23 "$fs" "$db"
80 }