diff --git a/.gitignore b/.gitignore index d1c9076..5c9b4fa 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ !README.md !sce.bat !sce.sh +!sce_completion.sh \ No newline at end of file diff --git a/sce.sh b/sce.sh index 0a79c58..44586ec 100755 --- a/sce.sh +++ b/sce.sh @@ -110,6 +110,7 @@ then # For other shells (Bash, Zsh, etc.) echo "# for the sce dev tool" echo "alias sce=\"$(pwd)/sce.sh\"" + echo "source \"$(pwd)/sce_completion.sh\"" echo "" exit 0 fi diff --git a/sce_completion.sh b/sce_completion.sh new file mode 100644 index 0000000..d934432 --- /dev/null +++ b/sce_completion.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +_sce_completion() { + local cur prev opts repos + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="clone run link setup completion" + repos="Clark cleezy Quasar SCE-discord-bot SCEta" + + if [[ ${prev} == "clone" || ${prev} == "run" || ${prev} == "link" ]]; then + COMPREPLY=( $(compgen -W "${repos}" -- ${cur}) ) + else + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + fi + + if [[ ${#COMPREPLY[@]} -eq 0 ]]; then + COMPREPLY=( $(compgen -o default -- ${cur}) ) + fi + + return 0 +} +complete -F _sce_completion sce