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 Dec 31, 2020
1 parent ce4481f commit 6337312
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions fish_completions.go
Original file line number Diff line number Diff line change
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 6337312

Please sign in to comment.