Skip to content

Instantly share code, notes, and snippets.

@joetde
Last active August 29, 2015 14:27
Show Gist options
  • Save joetde/192735c40c6248f17a5d to your computer and use it in GitHub Desktop.
Save joetde/192735c40c6248f17a5d to your computer and use it in GitHub Desktop.
_S_complete()
{
local cur=${COMP_WORDS[COMP_CWORD]}
local first=${COMP_WORDS[1]}
case ${COMP_CWORD} in
1)
COMPREPLY=( $(compgen -W "$(find $SCRIPT_DIRECTORIES -maxdepth 1 -type f -printf '%f\n')" -- $cur) )
;;
*)
if [[ $cur == -* ]]
then
local script=$(ls $SCRIPT_DIRECTORIES/$first)
COMPREPLY=( $(compgen -W "$(get_help $script)" -- $cur) )
else
COMPREPLY=( $(compgen -W "$(ls)" -- $cur) )
fi
;;
esac
}
complete -F _S_complete S
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment