Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#246305: zsh: completion for sudo doesn't add commands under root's path



This is how to achieve the equivalent effects with the patch at the
bottom, which could probably use some deuglification/optimization.
Should I commit?

> zstyle ':completion:*:sudo:*' command-path delete . .. '../*'

zstyle -e ':completion:*:sudo:*' command-path 'reply=(${path:#(.|..|../*})'

> zstyle ':completion:*:sudo:*' command-path append /usr/local/bin /opt/bin

zstyle -e ':completion:*:sudo:*' command-path 'reply=($path /usr/local/bin /opt/bin)'

> zstyle ':completion:*:sudo:*' command-path prepend ~/bin /usr/local/bin

zstyle -e ':completion:*:sudo:*' command-path 'reply=(~/bin /usr/local/bin $path)'

> zstyle ':completion:*:sudo:*' command-path assign /bin /usr/bin /usr/sbin

zstyle ':completion:*:sudo:*' command-path /bin /usr/bin /usr/sbin

> (This begs the question of what to do if you want to add things at both
> the end and the beginning.)

zstyle -e ':completion:*:sudo:*' command-path 'reply=(~/bin $path /usr/local/bin /opt/bin)'
Though I don't see the significance of path order.

Index: Completion/Zsh/Type/_command_names
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Type/_command_names,v
retrieving revision 1.6
diff -u -r1.6 _command_names
--- Completion/Zsh/Type/_command_names	3 Sep 2003 10:15:35 -0000	1.6
+++ Completion/Zsh/Type/_command_names	1 May 2004 04:57:49 -0000
@@ -33,4 +33,13 @@
 
 args=( "$@" )
 
+{
+local -a oldpath
+oldpath=( $path )
+local -A +h commands
+local -a cmdpath
+zstyle -a ":completion:${curcontext}" command-path cmdpath
+local -a +h path
+[[ $#cmdpath -gt 0 ]] && path=( $cmdpath ) || path=( $oldpath )
 _alternative -O args "$defs[@]"
+}



Messages sorted by: Reverse Date, Date, Thread, Author