Skip to content

Commit

Permalink
Fix zsh completion for sudo
Browse files Browse the repository at this point in the history
SUDO_PATHを使う方式にしてみたが、sudoを sudo env PATH=hoge の
エイリアスにしたところzsh-syntax-highlightingのハイライトが
意図した通りの挙動にならなかった。(詳しくは
highlighting for sudo commands #107
zsh-users/zsh-syntax-highlighting#107
を参照のこと。)
それに btrfs version とか--helpオプションのように、sbin系でも
一般ユーザが実行して成功して終了できる場合があるので、やっぱり
sudo以外の場合でも実行できてほしい。
そんなわけで元に戻してsbin系もPATHに含めた。
  • Loading branch information
Larry committed Nov 9, 2014
1 parent c88f827 commit f906240
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions common/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ path=(

export PATH

# for sudo
# for sudo and sbin commands
if [[ $EUID != 0 ]] ; then
typeset -xT SUDO_PATH sudo_path
typeset -U sudo_path
Expand All @@ -102,8 +102,10 @@ if [[ $EUID != 0 ]] ; then
/usr/sbin(N-/)
/sbin(N-/)
)
path=($path $sudo_path)
fi
zstyle ':completion:*:sudo:*' environ PATH="$SUDO_PATH:$PATH"
#zstyle ':completion:*:sudo:*' environ PATH="$SUDO_PATH:$PATH"
zstyle ':completion:*:sudo:*' command-path $path


## path to completion and prompts configuration
Expand Down
4 changes: 2 additions & 2 deletions common/.zshrc.alias
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Alias configuration

# enable alias expansion of commands after sudo command with a space after "sudo".
#alias sudo="sudo "
alias sudo="sudo env PATH=\"$SUDO_PATH:${PATH}\" "
alias sudo="sudo "
#alias sudo="sudo env PATH=\"$SUDO_PATH:${PATH}\" "

alias where="command -v"
alias j="jobs -l"
Expand Down

0 comments on commit f906240

Please sign in to comment.