2009-06-08 16:45:09 +02:00
|
|
|
# bash completion for yp-tools
|
|
|
|
|
|
|
|
_ypmatch()
|
|
|
|
{
|
2011-04-21 11:04:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-06-08 16:45:09 +02:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
local map cmd=${1##*/}
|
2009-06-08 16:45:09 +02:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
[[ $cmd == ypcat && $cword -gt 1 ]] && return 0
|
|
|
|
[[ $cmd == ypmatch && $cword -gt 2 ]] && return 0
|
2009-06-08 16:45:09 +02:00
|
|
|
|
2011-04-21 11:04:51 +03:00
|
|
|
if [[ $cmd == ypmatch && $cword -eq 1 && ${#words[@]} -eq 3 ]]; then
|
|
|
|
map=${words[2]}
|
add_members, bk, gcc, mtx, munin-run, munindoc, mutt, p4, portinstall, postmap, ri, ypmatch: Avoid stderr spewage when needed commands/dirs are not available.
2011-10-22 11:48:23 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$( ypcat $map 2>/dev/null | \
|
2009-10-04 19:42:50 +02:00
|
|
|
cut -d':' -f 1 )' -- "$cur") )
|
|
|
|
else
|
2011-04-21 11:04:51 +03:00
|
|
|
[[ $cmd == ypmatch && $cword -ne 2 ]] && return 0
|
2009-10-04 19:42:50 +02:00
|
|
|
COMPREPLY=( $( compgen -W \
|
add_members, bk, gcc, mtx, munin-run, munindoc, mutt, p4, portinstall, postmap, ri, ypmatch: Avoid stderr spewage when needed commands/dirs are not available.
2011-10-22 11:48:23 +03:00
|
|
|
'$( printf "%s\n" $(ypcat -x 2>/dev/null | \
|
|
|
|
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
|
2009-10-01 20:54:51 +03:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# mode: shell-script
|
2009-10-04 19:42:50 +02:00
|
|
|
# sh-basic-offset: 4
|
2009-10-01 20:54:51 +03:00
|
|
|
# sh-indent-comment: t
|
2009-10-04 19:42:50 +02:00
|
|
|
# indent-tabs-mode: nil
|
2009-10-01 20:54:51 +03:00
|
|
|
# End:
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|