38 lines
882 B
Plaintext
Raw Normal View History

2009-06-08 16:45:09 +02:00
# bash completion for yp-tools
have ypcat || return
2009-06-08 16:45:09 +02:00
_ypmatch()
{
local cur map cmd
2009-06-08 16:45:09 +02:00
2009-10-04 19:42:50 +02:00
COMPREPLY=()
_get_comp_words_by_ref cur
cmd=${1##*/}
2009-06-08 16:45:09 +02:00
[[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0
[[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
2009-06-08 16:45:09 +02:00
if [[ $cmd == 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
[[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W \
2009-12-21 00:09:02 +02:00
'$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
2009-10-04 19:42:50 +02:00
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