diff --git a/AUTHORS b/AUTHORS index 3f511216c..39eb8afbe 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,6 +34,9 @@ Quentin Perez Quentin Perez ReadmeCritic Renovate Bot +Robert Loomans Robin Schneider +Sergei Dyshel Tin Lai +Will Fantom Will O <0100wrxb@gmail.com> diff --git a/contrib/completion/bash_autocomplete b/contrib/completion/bash_autocomplete index bb88f40ff..b7096afeb 100644 --- a/contrib/completion/bash_autocomplete +++ b/contrib/completion/bash_autocomplete @@ -661,7 +661,7 @@ _assh_root_command() __start_assh() { - local cur prev words cword + local cur prev words cword split declare -A flaghash 2>/dev/null || : declare -A aliashash 2>/dev/null || : if declare -F _init_completion >/dev/null 2>&1; then @@ -677,11 +677,13 @@ __start_assh() local flags_with_completion=() local flags_completion=() local commands=("assh") + local command_aliases=() local must_have_one_flag=() local must_have_one_noun=() local has_completion_function local last_command local nouns=() + local noun_aliases=() __assh_handle_word } diff --git a/contrib/completion/zsh_autocomplete b/contrib/completion/zsh_autocomplete index 85eb205c7..f37fcdf3b 100644 --- a/contrib/completion/zsh_autocomplete +++ b/contrib/completion/zsh_autocomplete @@ -18,7 +18,7 @@ _assh() local shellCompDirectiveFilterFileExt=8 local shellCompDirectiveFilterDirs=16 - local lastParam lastChar flagPrefix requestComp out directive compCount comp lastComp + local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace local -a completions __assh_debug "\n========= starting completion logic ==========" @@ -86,7 +86,6 @@ _assh() return fi - compCount=0 while IFS='\n' read -r comp; do if [ -n "$comp" ]; then # If requested, completions are returned with a description. @@ -98,13 +97,17 @@ _assh() local tab=$(printf '\t') comp=${comp//$tab/:} - ((compCount++)) __assh_debug "Adding completion: ${comp}" completions+=${comp} lastComp=$comp fi done < <(printf "%s\n" "${out[@]}") + if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then + __assh_debug "Activating nospace." + noSpace="-S ''" + fi + if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then # File extension filtering local filteringCmd @@ -131,25 +134,40 @@ _assh() __assh_debug "Listing directories in ." fi + local result _arguments '*:dirname:_files -/'" ${flagPrefix}" + result=$? if [ -n "$subdir" ]; then popd >/dev/null 2>&1 fi - elif [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ] && [ ${compCount} -eq 1 ]; then - __assh_debug "Activating nospace." - # We can use compadd here as there is no description when - # there is only one completion. - compadd -S '' "${lastComp}" - elif [ ${compCount} -eq 0 ]; then - if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then - __assh_debug "deactivating file completion" + return $result + else + __assh_debug "Calling _describe" + if eval _describe "completions" completions $flagPrefix $noSpace; then + __assh_debug "_describe found some completions" + + # Return the success of having called _describe + return 0 else - # Perform file completion - __assh_debug "activating file completion" - _arguments '*:filename:_files'" ${flagPrefix}" + __assh_debug "_describe did not find completions." + __assh_debug "Checking if we should do file completion." + if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then + __assh_debug "deactivating file completion" + + # We must return an error code here to let zsh know that there were no + # completions found by _describe; this is what will trigger other + # matching algorithms to attempt to find completions. + # For example zsh can match letters in the middle of words. + return 1 + else + # Perform file completion + __assh_debug "Activating file completion" + + # We must return the result of this command, so it must be the + # last command, or else we must store its result to return it. + _arguments '*:filename:_files'" ${flagPrefix}" + fi fi - else - _describe "completions" completions $(echo $flagPrefix) fi }