Small yp-tools completion improvements.
Install ypmatch completion only if ypcat is available instead of the other way around, fix completions when commands are invoked using paths to them.
This commit is contained in:
parent
eb70bc8431
commit
19ca031a08
2
CHANGES
2
CHANGES
@ -27,7 +27,7 @@ bash-completion (2.x)
|
|||||||
* Remove many unnecessary short option completions where long ones exist.
|
* Remove many unnecessary short option completions where long ones exist.
|
||||||
* Improve chsh, configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
|
* Improve chsh, configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
|
||||||
mysqladmin, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
|
mysqladmin, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
|
||||||
vncviewer, and general hostname completions.
|
vncviewer, yp-tools, and general hostname completions.
|
||||||
* Add abook and wtf completion, based on work by Raphaël Droz.
|
* Add abook and wtf completion, based on work by Raphaël Droz.
|
||||||
* Add cvsps, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake, pack200
|
* Add cvsps, fusermount, jarsigner, k3b, lftpget, pm-utils, rtcwake, pack200
|
||||||
and unpack200 completions.
|
and unpack200 completions.
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
# bash completion for yp-tools
|
# bash completion for yp-tools
|
||||||
|
|
||||||
have ypmatch &&
|
have ypcat &&
|
||||||
_ypmatch()
|
_ypmatch()
|
||||||
{
|
{
|
||||||
local cur map
|
local cur map cmd
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur=`_get_cword`
|
cur=`_get_cword`
|
||||||
|
cmd=${1##*/}
|
||||||
|
|
||||||
[[ $1 == ypcat && $COMP_CWORD -gt 1 ]] && return 0
|
[[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0
|
||||||
[[ $1 == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
|
[[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
|
||||||
|
|
||||||
if [[ $1 == ypmatch && $COMP_CWORD -eq 1 && ${#COMP_WORDS[@]} -eq 3 ]]; then
|
if [[ $cmd == ypmatch && $COMP_CWORD -eq 1 && \
|
||||||
|
${#COMP_WORDS[@]} -eq 3 ]]; then
|
||||||
map=${COMP_WORDS[2]}
|
map=${COMP_WORDS[2]}
|
||||||
COMPREPLY=( $( compgen -W '$( ypcat $map | \
|
COMPREPLY=( $( compgen -W '$( ypcat $map | \
|
||||||
cut -d':' -f 1 )' -- "$cur") )
|
cut -d':' -f 1 )' -- "$cur") )
|
||||||
else
|
else
|
||||||
[[ $1 == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
|
[[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
|
||||||
COMPREPLY=( $( compgen -W \
|
COMPREPLY=( $( compgen -W \
|
||||||
'$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
|
'$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user