]> git.rmz.io Git - dotfiles.git/blobdiff - zsh/aliases/pacman.zsh
xdg: add user-dirs.dirs
[dotfiles.git] / zsh / aliases / pacman.zsh
index 5047b319beceaa0bb6c505d5a1dc15c928d9ac34..ba27286f20f24be547fb038ac0c6e7d1ca06da62 100644 (file)
@@ -1,9 +1,13 @@
+if (( ! $+commands[pacman] )); then
+    return 1
+fi
+
 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
 alias pacupg='sudo pacman -Syu'        # Synchronize with repositories before upgrading packages that are out of date on the local system.
 alias pacin='sudo pacman -S'           # Install specific package(s) from the repositories
 alias pacu='sudo pacman -U'            # Install specific package not from the repositories but from a file
 alias pacre='sudo pacman -R'           # Remove the specified package(s), retaining its configuration(s) and required dependencies
 # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
 alias pacupg='sudo pacman -Syu'        # Synchronize with repositories before upgrading packages that are out of date on the local system.
 alias pacin='sudo pacman -S'           # Install specific package(s) from the repositories
 alias pacu='sudo pacman -U'            # Install specific package not from the repositories but from a file
 alias pacre='sudo pacman -R'           # Remove the specified package(s), retaining its configuration(s) and required dependencies
-alias pacrem='sudo pacman -Rns'        # Remove the specified package(s), its configuration(s) and unneeded dependencies
+alias pacrem='sudo pacman -Rns'        # Remove the specified package(s) and unneeded dependencies
 alias pacrm='sudo pacman -Rnsc'        # Remove the specified package(s), its configuration(s) and unneeded dependencies
 alias pacsi='pacman -Sii'              # Display information about a given package in the repositories
 alias pacss='pacman -Ss'               # Search for package(s) in the repositories
 alias pacrm='sudo pacman -Rnsc'        # Remove the specified package(s), its configuration(s) and unneeded dependencies
 alias pacsi='pacman -Sii'              # Display information about a given package in the repositories
 alias pacss='pacman -Ss'               # Search for package(s) in the repositories
@@ -20,7 +24,7 @@ alias pacmir='sudo pacman -Syy'                # Force refresh of all package li
 
 # https://bbs.archlinux.org/viewtopic.php?id=93683
 paclist() {
 
 # https://bbs.archlinux.org/viewtopic.php?id=93683
 paclist() {
-  pacman -Qei | awk 'BEGIN {FS=": "}/^Name/{printf("\033[1;36m%s\033[0m ",$2)}/^Description/{print $2}'
+  pacman -Qei "$@" | awk 'BEGIN {FS=": "}/^Name/{printf("\033[1;36m%s\033[0m ",$2)}/^Description/{print $2}'
 }
 # [l]ist [o]orphans
 alias paclo='pacman -Qdt'
 }
 # [l]ist [o]orphans
 alias paclo='pacman -Qdt'
@@ -30,7 +34,7 @@ alias pacro='sudo pacman -Rnscu $(pacman -Qtdq)'
 # Display information about given packages (merges output of -Sii and -Qii)
 paci() {
     for p in $@; do
 # Display information about given packages (merges output of -Sii and -Qii)
 paci() {
     for p in $@; do
-        if [[ -n "$(pacman -Qq "$p" 2>/dev/null)" ]]; then 
+        if [[ -n "$(pacman -Qq "$p" 2>/dev/null)" ]]; then
             diff -u100 <(pacman -Qii "$p") <(pacman -Sii "$p" | sed '/^$/,$ d') | sed -e '1,3 d' -e 's/[-+ ]//'
         else
             pacman -Sii "$p"
             diff -u100 <(pacman -Qii "$p") <(pacman -Sii "$p" | sed '/^$/,$ d') | sed -e '1,3 d' -e 's/[-+ ]//'
         else
             pacman -Sii "$p"
@@ -41,6 +45,11 @@ paci() {
 compdef '_pacman_completions_all_packages' paci=pacman
 
 pacstat() {
 compdef '_pacman_completions_all_packages' paci=pacman
 
 pacstat() {
+  printf "Packages:\n"
+  printf "%7d native\n"  $(LC_ALL=C pacman -Qn | wc -l)
+  printf "%7d foreign\n" $(LC_ALL=C pacman -Qm | wc -l)
+  printf "%7d total\n"   $(LC_ALL=C pacman -Q  | wc -l)
+  printf "Repos:\n"
   LC_ALL=C pacman -Sl | sed -n '/\[installed\]/s/^\([^ ]*\).*/\1/p' | uniq -c
 }
 
   LC_ALL=C pacman -Sl | sed -n '/\[installed\]/s/^\([^ ]*\).*/\1/p' | uniq -c
 }
 
@@ -54,8 +63,17 @@ pacdisowned() {
 
   pacman -Qlq | sort -u > "$db"
 
 
   pacman -Qlq | sort -u > "$db"
 
-  find /bin /etc /lib /sbin /usr \
-      ! \( -name lost+found -o -name local -o -path "*/share/mime/*" \) \
+  local -a d
+  if [[ -z $@ ]]; then
+    d=(/etc /usr)
+  else
+    d=($@)
+  fi
+  find ${d[@]} \
+      ! \( -name lost+found \
+        -o -path '*/local/*' \
+        -o -path "*/share/mime/*" \
+        \) \
         \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
 
   comm -23 "$fs" "$db"
         \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
 
   comm -23 "$fs" "$db"