Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: user-sensitive kill completion in conjunction with sudo
- X-seq: zsh-users 13311
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: user-sensitive kill completion in conjunction with sudo
- Date: Tue, 07 Oct 2008 21:55:16 -0700
- In-reply-to: <17393e3e0810072010x23f66940sc1f5c3d8ac25a06@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <17393e3e0810072010x23f66940sc1f5c3d8ac25a06@xxxxxxxxxxxxxx>
On Oct 7, 11:10pm, Matt Wozniski wrote:
}
} Is there some easy (or even difficult) way to modify this to handle
} the user 'kill' will be executed as?
This should do it, but see commentary caveats.
pids4kill() {
local -a ps
# This is using inside knowledge of the implementation.
# Not guaranteed to work across upgrades, but likely to.
if [[ $oldcontext = *:sudo:* ]]
then
# More inside knowledge: Peek at the sudo options.
# Also not guaranteed to work across upgrades.
local u=$opt_args[-u]
if [[ -n $u ]]
then
ps=(ps -u $u)
else
ps=(ps -u root)
fi
else
ps=(ps -u $USER)
fi
$ps -o pid,%cpu,tty,cputime,cmd
}
zstyle ':completion:*:*:kill:*' command pids4kill
Messages sorted by:
Reverse Date,
Date,
Thread,
Author