From 57327f9d067ab520ed42b450ebcbf02152e38975 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 20 Dec 2017 08:39:22 +0100 Subject: [PATCH] Don't run command with sudo for root. --- zshrc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/zshrc b/zshrc index ac96b8c..20518a8 100644 --- a/zshrc +++ b/zshrc @@ -60,8 +60,8 @@ if [ ${USER} != "root" ]; then alias sj='sudo journalctl ' alias sn='sudo nft list ruleset' alias sp='sudo puppet agent -t ' - alias sv='sudo -E vi ' - alias sz='sudo -E zsh' + alias sv='sudo vi ' + alias sz='sudo zsh' else alias sc='systemctl ' 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' # 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 @@ -361,11 +361,15 @@ alias stat_sys="echo ' ' && uname -a && echo ' '&& uptime &&echo ' '&& df && ech # Sudo function sudo() { - 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" + if [ ${USER} = "root" ]; then + "${@}" 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 }