Don't run command with sudo for root.

This commit is contained in:
Jeremy Gardais 2017-12-20 08:39:22 +01:00
parent 102b8315ca
commit 57327f9d06
1 changed files with 11 additions and 7 deletions

18
zshrc
View File

@ -60,8 +60,8 @@ if [ ${USER} != "root" ]; then
alias sj='sudo journalctl ' alias sj='sudo journalctl '
alias sn='sudo nft list ruleset' alias sn='sudo nft list ruleset'
alias sp='sudo puppet agent -t ' alias sp='sudo puppet agent -t '
alias sv='sudo -E vi ' alias sv='sudo vi '
alias sz='sudo -E zsh' alias sz='sudo zsh'
else else
alias sc='systemctl ' alias sc='systemctl '
alias sd='docker' alias sd='docker'
@ -144,7 +144,7 @@ fi
alias wotgobblemem='ps -o time,ppid,pid,nice,pcpu,pmem,user,comm -A | sort -n -k 6 | tail -15' alias wotgobblemem='ps -o time,ppid,pid,nice,pcpu,pmem,user,comm -A | sort -n -k 6 | tail -15'
# Afficher uniquement le processus à partir de ps # Afficher uniquement le processus à partir de ps
alias px='ps faux|grep -v grep|grep -i -e VSZ -e --' alias px='ps faux|grep -v grep|grep -i -e VSZ -e '
# Décompression # Décompression
@ -361,11 +361,15 @@ alias stat_sys="echo ' ' && uname -a && echo ' '&& uptime &&echo ' '&& df && ech
# Sudo # Sudo
function sudo() { function sudo() {
if alias "${1}" &> /dev/null ; then if [ ${USER} = "root" ]; then
#$(type "$1" | sed -E 's/^.*`(.*).$/\1/') "${@:2}" "${@}"
command -v "${1}" | \grep -o -P "(?<=\').*(?=')" | xargs sudo -E env "PATH=$PATH"
else else
command sudo -E env "PATH=$PATH" "$@" if alias "${1}" &> /dev/null ; then
#$(type "$1" | sed -E 's/^.*`(.*).$/\1/') "${@:2}"
command -v "${1}" | \grep -o -P "(?<=\').*(?=')" | xargs sudo -E env "PATH=$PATH"
else
command sudo -E env "PATH=$PATH" "$@"
fi
fi fi
} }