35 lines
817 B
Plaintext
Raw Normal View History

2009-06-08 16:45:09 +02:00
# bash completion for yp-tools
have ypmatch &&
_ypmatch()
{
2009-10-04 19:42:50 +02:00
local cur map
2009-06-08 16:45:09 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=()
cur=`_get_cword`
2009-06-08 16:45:09 +02:00
[[ $1 == ypcat && $COMP_CWORD -gt 1 ]] && return 0
[[ $1 == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
2009-06-08 16:45:09 +02:00
if [[ $1 == ypmatch && $COMP_CWORD -eq 1 && ${#COMP_WORDS[@]} -eq 3 ]]; then
2009-10-04 19:42:50 +02:00
map=${COMP_WORDS[2]}
COMPREPLY=( $( compgen -W '$( ypcat $map | \
cut -d':' -f 1 )' -- "$cur") )
else
[[ $1 == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W \
'$( echo $(ypcat -x | cut -d"\"" -f 2))' -- "$cur"))
fi
2009-06-08 16:45:09 +02:00
2009-10-04 19:42:50 +02:00
return 0
2009-06-08 16:45:09 +02:00
} &&
complete -F _ypmatch ypmatch ypcat
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh