Skip to content

Commit

Permalink
Support fish completion with env vars in the path
Browse files Browse the repository at this point in the history
Fixes #1214
Fixes #1306

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
  • Loading branch information
marckhouzam committed Jan 25, 2021
1 parent 0b1a206 commit 137f3b0
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions fish_completions.go
Expand Up @@ -43,16 +43,13 @@ function __%[1]s_perform_completion
end
__%[1]s_debug "emptyArg: $emptyArg"
if not type -q "$args[1]"
# This can happen when "complete --do-complete %[2]s" is called when running this script.
__%[1]s_debug "Cannot find $args[1]. No completions."
return
end
set requestComp "$args[1] %[3]s $args[2..-1] $emptyArg"
__%[1]s_debug "Calling $requestComp"
set results (eval $requestComp 2> /dev/null)
# Call the command as a sub-shell so that we can redirect any errors
# For example, if $requestComp has an unmatched quote
# https://github.com/spf13/cobra/issues/1214
set results (fish -c "$requestComp" 2> /dev/null)
set comps $results[1..-2]
set directiveLine $results[-1]
Expand Down

0 comments on commit 137f3b0

Please sign in to comment.