Last active
August 29, 2015 14:27
-
-
Save joetde/192735c40c6248f17a5d to your computer and use it in GitHub Desktop.
This file contains 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
_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