Created
April 15, 2011 00:45
-
-
Save kwilczynski/920908 to your computer and use it in GitHub Desktop.
MCollective's mco bash completion script to put into /etc/bash_completion.d/ directory ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*- | |
# ex: ts=8 sw=8 noet filetype=sh | |
# MCollective's mco completion by Krzysztof Wilczynski <[email protected]> | |
_mco() | |
{ | |
local current | |
COMPREPLY=() | |
current=$( _get_cword ) | |
current=${current//\\\\/} | |
if [[ ${COMP_CWORD} == 1 ]] && [[ "${current}" != -* ]] ; then | |
COMPREPLY=( ${COMPREPLY[@]} \ | |
"$( mco 2> /dev/null | \ | |
grep -i 'commands' | cut -d ':' -f 2 | \ | |
sed 's/^[ \t]*//;s/[ \t]*$//' | sort -u )" ) | |
COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "${current}") ) | |
elif [[ ${COMP_CWORD} > 1 ]] && [[ "${current}" == -* ]] ; then | |
COMPREPLY=( ${COMPREPLY[@]} \ | |
"-1 -A -c -C -F -h -I -q -t -T -v -W \ | |
--dt --ln --np --wa --wc --wf --wi \ | |
--config --help --one --quiet --target --timeout --verbose --with \ | |
--discovery-timeout --limit-nodes --no-progress \ | |
--with-agent --with-class --with-fact --with-identity" ) | |
COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- "${current}") ) | |
else | |
_filedir || return 0 | |
fi | |
return 0 | |
} | |
complete -F _mco $default mco |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment