From: "Andrej Borsenkow" <borsenkow.msk@sni.de>
To: "ZSH workers mailing list" <zsh-workers@sunsite.auc.dk>
Subject: sudo completion
Date: Tue, 16 Mar 1999 20:06:26 +0300 [thread overview]
Message-ID: <003901be6fcf$53d31b50$21c9ca95@mowp.siemens.ru> (raw)
As I quite often use sudo, I really like to have it. May be, it will be of
some use to others.
Just a comment - there is no way for sudo to run internal (builtin) command,
so, I explicitly complete only external commands if we are in command
position.
cheers
/andrej
P.S. I don't provide a it as a patch as I don't deem it good enough. It
works for me though ...
#defcomp sudo
emulate -RL zsh
##
## Get the position of the first non-option argument (it should be command)
## The $words[1] is always "sudo"
##
local -i i=1 cmd=0
while [[ $i -lt $#words ]]
do
case $words[++i] in
-? )
continue
;;
* )
if [[ $i -gt 2 && ($words[i-1] == -p || $words[i-1] == -u) ]]
then
continue
fi
cmd=$i
break
;;
esac
done
##
## If we are at the first non-option argument, simply complete it
## as if it were external command
## If we are after the first non-option argument, complete
## as if it were given command
## Else the only sesnible completion seems to be for -u (users)
##
if [[ $cmd -gt 0 && -position cmd ]]
then
compgen -m
elif [[ $cmd -gt 0 && -position cmd -1 ]]
_normal
elif [[ -current -1 -u ]]
then
compgen -u
else
return 0
fi
reply other threads:[~1999-03-17 9:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003901be6fcf$53d31b50$21c9ca95@mowp.siemens.ru' \
--to=borsenkow.msk@sni.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).