1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 13:58:00 +00:00

Don't use sudo if implicitly called by Pacman frontend

Don't rely on alias expansion to handle Pacman because aliases
are not expanded in sudo.

Signed-off-by: Sorin Ionescu <sorin.ionescu@gmail.com>
This commit is contained in:
Sebastian Wiesner 2013-12-09 15:29:14 +01:00 committed by Sorin Ionescu
parent 57b283facd
commit fa6723a5ee
2 changed files with 19 additions and 17 deletions

View File

@ -27,6 +27,8 @@ if (( $+commands[$_pacman_frontend] )); then
if [[ -s "${0:h}/${_pacman_frontend}.zsh" ]]; then
source "${0:h}/${_pacman_frontend}.zsh"
fi
else
_pacman_sudo='sudo '
fi
#
@ -34,49 +36,49 @@ fi
#
# Pacman.
alias pac='pacman'
alias pac= "${_pacman_frontend}"
# Installs packages from repositories.
alias paci='sudo pacman --sync'
alias paci="${_pacman_sudo}${_pacman_frontend} --sync"
# Installs packages from files.
alias pacI='sudo pacman --upgrade'
alias pacI="${_pacman_sudo}${_pacman_frontend} --upgrade"
# Removes packages and unneeded dependencies.
alias pacx='sudo pacman --remove'
alias pacx="${_pacman_sudo}${_pacman_frontend} --remove"
# Removes packages, their configuration, and unneeded dependencies.
alias pacX='sudo pacman --remove --nosave --recursive'
alias pacX="${_pacman_sudo}${_pacman_frontend} --remove --nosave --recursive"
# Displays information about a package from the repositories.
alias pacq='pacman --sync --info'
alias pacq="${_pacman_frontend} --sync --info"
# Displays information about a package from the local database.
alias pacQ='pacman --query --info'
alias pacQ="${_pacman_frontend} --query --info"
# Searches for packages in the repositories.
alias pacs='pacman --sync --search'
alias pacs="${_pacman_frontend} --sync --search"
# Searches for packages in the local database.
alias pacS='pacman --query --search'
alias pacS="${_pacman_frontend} --query --search"
# Lists orphan packages.
alias pacman-list-orphans='sudo pacman --query --deps --unrequired'
alias pacman-list-orphans="${_pacman_sudo}${_pacman_frontend} --query --deps --unrequired"
# Removes orphan packages.
alias pacman-remove-orphans='sudo pacman --remove --recursive $(pacman --quiet --query --deps --unrequired)'
alias pacman-remove-orphans="${_pacman_sudo}${_pacman_frontend} --remove --recursive \$(${_pacman_frontend} --quiet --query --deps --unrequired)"
# Synchronizes the local package and Arch Build System databases against the
# repositories.
if (( $+commands[abs] )); then
alias pacu='sudo pacman --sync --refresh && sudo abs'
alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh && ${_pacman_sudo}abs"
else
alias pacu='sudo pacman --sync --refresh'
alias pacu="${_pacman_sudo}${_pacman_frontend} --sync --refresh"
fi
# Synchronizes the local package database against the repositories then
# upgrades outdated packages.
alias pacU='sudo pacman --sync --refresh --sysupgrade'
alias pacU="${_pacman_sudo}${_pacman_frontend} --sync --refresh --sysupgrade"
unset _pacman_frontend
unset _pacman_{frontend,sudo}

View File

@ -11,9 +11,9 @@
# Disable color.
if ! zstyle -t ':prezto:module:pacman:yaourt' color; then
alias pacman='pacman --nocolor'
alias pacman='yaourt --nocolor'
fi
# Manages .pac* files.
alias pacc='pacman -C'
alias pacc='yaourt -C'