From aa36c9db69cbe904e47ea36b9f42f81e8beea984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 4 Aug 2023 09:08:32 +0300 Subject: [PATCH 1/2] feat(pipenv): add fallback 3rd party completion loader https://pipenv.pypa.io/en/latest/shell/#shell-completion --- completions/Makefile.am | 1 + completions/_pipenv | 15 +++++++++++++++ test/fallback/completions/Makefile.am | 1 + test/fallback/completions/pipenv | 1 + 4 files changed, 18 insertions(+) create mode 100644 completions/_pipenv create mode 120000 test/fallback/completions/pipenv diff --git a/completions/Makefile.am b/completions/Makefile.am index ddf85f9dd35..4981257b379 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -316,6 +316,7 @@ bashcomp_DATA = 2to3 \ pidof \ pine \ ping \ + _pipenv \ pkg-config \ pkg-get \ pkg_delete \ diff --git a/completions/_pipenv b/completions/_pipenv new file mode 100644 index 00000000000..d1b461a632e --- /dev/null +++ b/completions/_pipenv @@ -0,0 +1,15 @@ +# 3rd party completion loader for commands emitting -*- shell-script -*- +# their completion using "_${cmdname^^}_COMPLETE=bash_source $cmd". +# This pattern is used by programs built with https://click.palletsprojects.com +# +# This serves as a fallback in case the completion is not installed otherwise. + +eval -- "$( + # shellcheck disable=SC2154 + ucname="${cmdname^^}" + ucname=${ucname//-/_} + eval "v=_${ucname}_COMPLETE=bash_source; export \$v" + "$1" 2>/dev/null +)" + +# ex: filetype=sh diff --git a/test/fallback/completions/Makefile.am b/test/fallback/completions/Makefile.am index 9643bf118a0..ef1af3fcc0c 100644 --- a/test/fallback/completions/Makefile.am +++ b/test/fallback/completions/Makefile.am @@ -24,6 +24,7 @@ EXTRA_DIST = \ newgrp \ nmcli \ nox \ + pipenv \ renice \ repomanage \ reptyr \ diff --git a/test/fallback/completions/pipenv b/test/fallback/completions/pipenv new file mode 120000 index 00000000000..faa7ea36980 --- /dev/null +++ b/test/fallback/completions/pipenv @@ -0,0 +1 @@ +../../../completions/_pipenv \ No newline at end of file From fd3cff1bc25c21f4cbfbc09f31bf9e3c17f4bd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 26 Aug 2023 12:34:05 +0300 Subject: [PATCH 2/2] fixup! feat(pipenv): add fallback 3rd party completion loader Co-authored-by: Koichi Murase --- completions/_pipenv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completions/_pipenv b/completions/_pipenv index d1b461a632e..e6d2df6aa52 100644 --- a/completions/_pipenv +++ b/completions/_pipenv @@ -8,7 +8,7 @@ eval -- "$( # shellcheck disable=SC2154 ucname="${cmdname^^}" ucname=${ucname//-/_} - eval "v=_${ucname}_COMPLETE=bash_source; export \$v" + export "_${ucname}_COMPLETE=bash_source" "$1" 2>/dev/null )"