diff --git a/src/dropshell-completion.bash b/src/dropshell-completion.bash index fa51aa5..f365d31 100755 --- a/src/dropshell-completion.bash +++ b/src/dropshell-completion.bash @@ -5,6 +5,7 @@ _dropshell_completions() { COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" + root="${COMP_WORDS[1]}" # List of main commands opts="help version servers templates autocomplete_list_servers autocomplete_list_services autocomplete_list_commands install backup" @@ -20,8 +21,8 @@ _dropshell_completions() { fi # Command-specific completions - case "${prev}" in - status|templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands) + case "${root}" in + templates|autocomplete_list_servers|autocomplete_list_services|autocomplete_list_commands) # No additional completions for these commands COMPREPLY=() return 0 @@ -49,7 +50,7 @@ _dropshell_completions() { ;; *) # if ${prev} is not in ${commands} - if [[ ! " ${commands[*]} " =~ " ${prev} " ]]; then + if [[ ! " ${commands[*]} " =~ " ${root} " ]]; then COMPREPLY=() return 0 fi