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

Re: sudo processes completion with zstyle -e



On Apr 7,  1:25am, Sebastian Stark wrote:
} 
} When using sudo it seems the $words array is not that useful in the  
} following context:
} 
}    zstyle -e ':completion:*:processes' command 'if [[ $words[1] ==  
} sudo ]] reply="ps auxw"'

That's because the _sudo function is defined to call the _normal
completer on everything after the command name argument, which has
the effect of hiding the "sudo" and making the completion system
believe that the command line begins with "kill", so that options
etc. for kill are completed.

} Is there another way to find out whether a command is run with sudo?  

Try this:

    zstyle -e ':completion:*:processes' command \
      'if (( $funcstack[(eI)$_comps[sudo]] )) reply="ps auxw"'

That says "if the current call stack includes the completer for sudo,
then ...".



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