Skip to content

Commit f51f2f0

Browse files
authored
Merge pull request #1048 from akinomyoga/more-3rdparty-202309
feat: add fallback 3rd-party completion loaders
2 parents f260fa8 + c69845a commit f51f2f0

File tree

11 files changed

+84
-1
lines changed

11 files changed

+84
-1
lines changed

completions/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
/c++
3939
/cc
4040
/cdrecord
41+
/_chezmoi
4142
/chrome
4243
/chromium
4344
/ci
@@ -52,10 +53,12 @@
5253
/compare
5354
/compgen
5455
/composite
56+
/_conda
5557
/conjure
5658
/_constellation
5759
/_consul
5860
/cowthink
61+
/_crc
5962
/createdb
6063
/createuser
6164
/_cz
@@ -193,6 +196,8 @@
193196
/neomutt
194197
/_nfpm
195198
/_nomad
199+
/_npm
200+
/_oc
196201
/_okteto
197202
/_op
198203
/_ory
@@ -206,6 +211,7 @@
206211
/pinfo
207212
/ping4
208213
/ping6
214+
/_pip3
209215
/pkg_deinstall
210216
/pkg_info
211217
/pkgconf
@@ -302,6 +308,8 @@
302308
/_tanzu-core
303309
/_tendermint
304310
/_terraform
311+
/_tkn
312+
/_tkn-pac
305313
/tightvncviewer
306314
/tracepath6
307315
/_trivy

completions/Makefile.am

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ bashcomp_DATA = 2to3 \
208208
jshint \
209209
json_xs \
210210
jsonschema \
211+
_jungle \
211212
k3b \
212213
kcov \
213214
_keyring \
@@ -216,6 +217,7 @@ bashcomp_DATA = 2to3 \
216217
kldload \
217218
kldunload \
218219
koji \
220+
_kontena \
219221
ktutil \
220222
larch \
221223
lastlog \
@@ -299,6 +301,7 @@ bashcomp_DATA = 2to3 \
299301
nslookup \
300302
nsupdate \
301303
ntpdate \
304+
_nvm \
302305
oggdec \
303306
openssl \
304307
opera \
@@ -316,6 +319,7 @@ bashcomp_DATA = 2to3 \
316319
pidof \
317320
pine \
318321
ping \
322+
_pip \
319323
_pipenv \
320324
pkg-config \
321325
pkg-get \
@@ -550,6 +554,7 @@ CLEANFILES = \
550554
c++ \
551555
cc \
552556
cdrecord \
557+
_chezmoi \
553558
chrome \
554559
chromium \
555560
ci \
@@ -564,10 +569,12 @@ CLEANFILES = \
564569
compare \
565570
compgen \
566571
composite \
572+
_conda \
567573
conjure \
568574
_constellation \
569575
_consul \
570576
cowthink \
577+
_crc \
571578
createdb \
572579
createuser \
573580
_cz \
@@ -733,6 +740,8 @@ CLEANFILES = \
733740
neomutt \
734741
_nfpm \
735742
_nomad \
743+
_npm \
744+
_oc \
736745
_okteto \
737746
_op \
738747
_ory \
@@ -746,6 +755,7 @@ CLEANFILES = \
746755
pinfo \
747756
ping4 \
748757
ping6 \
758+
_pip3 \
749759
pkg_deinstall \
750760
pkg_info \
751761
pkgconf \
@@ -860,6 +870,8 @@ CLEANFILES = \
860870
_tanzu-core \
861871
_tendermint \
862872
_terraform \
873+
_tkn \
874+
_tkn-pac \
863875
tightvncviewer \
864876
tracepath6 \
865877
_trivy \
@@ -960,7 +972,7 @@ symlinks: $(DATA)
960972
$(ss) freeciv-server \
961973
civserver
962974
$(ss) _gaiacli \
963-
_gaiad _tendermint
975+
_gaiad _npm _tendermint
964976
$(ss) gcc \
965977
c++ cc f77 f95 g++ g++-5 g++-6 g++-7 g++-8 g77 g95 gcc-5 \
966978
gcc-6 gcc-7 gcc-8 gccgo gccgo-5 gccgo-6 gccgo-7 gccgo-8 gcj \
@@ -977,9 +989,11 @@ symlinks: $(DATA)
977989
_allero \
978990
_arduino-cli \
979991
_buf \
992+
_chezmoi \
980993
_cilium \
981994
_cloudquery \
982995
_constellation \
996+
_crc \
983997
_datree \
984998
_docker \
985999
_gardenctl \
@@ -1007,6 +1021,7 @@ symlinks: $(DATA)
10071021
_moldy \
10081022
_multi-gitter \
10091023
_nfpm \
1024+
_oc \
10101025
_okteto \
10111026
_op \
10121027
_ory \
@@ -1022,6 +1037,8 @@ symlinks: $(DATA)
10221037
_ssh-inscribe \
10231038
_tanzu \
10241039
_tanzu-core \
1040+
_tkn \
1041+
_tkn-pac \
10251042
_trivy \
10261043
_upctl \
10271044
_vacuum \
@@ -1102,6 +1119,7 @@ symlinks: $(DATA)
11021119
_ansible-playbook \
11031120
_ansible-pull \
11041121
_ansible-vault \
1122+
_conda \
11051123
_cz
11061124
$(ss) nslookup \
11071125
host
@@ -1113,6 +1131,8 @@ symlinks: $(DATA)
11131131
alpine
11141132
$(ss) ping \
11151133
ping4 ping6
1134+
$(ss) _pip \
1135+
_pip3
11161136
$(ss) _pipenv \
11171137
_black _blackd _flask _httpx
11181138
$(ss) pkg-config \

completions/_jungle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "_${cmdname^^}_COMPLETE=source $cmd".
3+
# This pattern is very similar to `completions/_pipenv`, but the value of the
4+
# environment variable is slightly different.
5+
#
6+
# This serves as a fallback in case the completion is not installed otherwise.
7+
8+
eval -- "$(
9+
# shellcheck disable=SC2154
10+
ucname="${cmdname^^}"
11+
ucname=${ucname//-/_}
12+
export "_${ucname}_COMPLETE=source"
13+
"$1" 2>/dev/null
14+
)"
15+
16+
# ex: filetype=sh

completions/_kontena

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 3rd party completion loader for kontena -*- shell-script -*-
2+
#
3+
# This serves as a fallback in case the completion is not installed otherwise.
4+
5+
# To avoid sourcing an empty string with `. "$(...)"` on failing to obtain the
6+
# path, we assign the output to a variable `_comp_cmd_kontena__completion_path`
7+
# and test it before sourcing. The variable is removed on successful loading
8+
# but left on a failure for the debugging purpose.
9+
_comp_cmd_kontena__completion_path=$("$1" whoami --bash-completion-path 2>/dev/null) &&
10+
[[ -r $_comp_cmd_kontena__completion_path ]] &&
11+
. "$_comp_cmd_kontena__completion_path" &&
12+
unset -v _comp_cmd_kontena__completion_path
13+
14+
# ex: filetype=sh

completions/_nvm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# 3rd party completion loader for nvm -*- shell-script -*-
2+
#
3+
# This serves as a fallback in case the completion is not installed otherwise.
4+
5+
# shellcheck disable=SC1091
6+
[[ ${NVM_DIR-} && -r $NVM_DIR/bash_completion ]] && . "$NVM_DIR"/bash_completion
7+
8+
# ex: filetype=sh

completions/_pip

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "$cmd completion --bash". For example, pip uses this
3+
# form of dynamic completions.
4+
#
5+
# This serves as a fallback in case the completion is not installed otherwise.
6+
7+
eval -- "$("$1" completion --bash 2>/dev/null)"
8+
9+
# ex: filetype=sh

test/fallback/completions/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ EXTRA_DIST = \
1414
hexdump \
1515
hwclock \
1616
ionice \
17+
jungle \
1718
keyring \
19+
kontena \
1820
look \
1921
mdbook \
2022
mock \
@@ -24,6 +26,8 @@ EXTRA_DIST = \
2426
newgrp \
2527
nmcli \
2628
nox \
29+
nvm \
30+
pip \
2731
pipenv \
2832
renice \
2933
repomanage \

test/fallback/completions/jungle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions/_jungle

test/fallback/completions/kontena

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions/_kontena

test/fallback/completions/nvm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions/_nvm

test/fallback/completions/pip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions/_pip

0 commit comments

Comments
 (0)