From 3e3996c9a5c8d2f77c762a4d6fd6e105aacc6551 Mon Sep 17 00:00:00 2001 From: exploide Date: Wed, 7 Sep 2022 12:46:26 +0200 Subject: [PATCH] completions pipenv: made pipenv completions compatible with recent versions pipenv switched from older click-completion package to new built-in completions from click framework in v2021.11.9. This command achieves compatibility with both, older and more recent versions. --- share/completions/pipenv.fish | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/share/completions/pipenv.fish b/share/completions/pipenv.fish index 84d85e25c..4dcd1be23 100644 --- a/share/completions/pipenv.fish +++ b/share/completions/pipenv.fish @@ -1,7 +1,12 @@ -if command -sq pipenv - # pipenv determines which completions to print via some automagic that might not be perfect. - # Force it to be correct. - _PIPENV_COMPLETE=source-fish pipenv --completion 2>/dev/null | source +# try new completion generation of click first +set -l comps (_PIPENV_COMPLETE=fish_source pipenv 2>/dev/null) +if test -z "$comps" || string match -q 'Usage:*' -- $comps + # fall back to older click-completion used in prior versions + set comps (_PIPENV_COMPLETE=source-fish pipenv --completion 2>/dev/null) end +set -q comps[1] && printf %s\n $comps | source + + +# manual workaround for pipenv run command completion until this is supported by the built-in mechanism complete -c pipenv -n "__fish_seen_subcommand_from run" -a "(__fish_complete_subcommand --fcs-skip=2)" -x