Skip to content

Commit df8cdda

Browse files
authored
Merge pull request #905 from scop/feat/3rd-party
feat: add 3rd party generated completion fallbacks
2 parents c3139e0 + 43da208 commit df8cdda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+133
-27
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ repos:
3434
files: ^test/t/.+\.py$
3535
pass_filenames: false
3636

37-
- id: update-test-deprecated-links
38-
name: update-test-deprecated-links
37+
- id: update-test-fallback-links
38+
name: update-test-fallback-links
3939
language: script
40-
entry: test/deprecated/update-deprecated-links
40+
entry: test/fallback/update-fallback-links
4141
files: ^completions/_
4242
pass_filenames: false
4343

bash_completion

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,9 @@ __load_completion()
25372537
backslash=\\
25382538
fi
25392539
2540+
# For loading 3rd party completions wrapped in shopt reset
2541+
local IFS=$' \t\n'
2542+
25402543
for dir in "${dirs[@]}"; do
25412544
[[ -d $dir ]] || continue
25422545
for compfile in "$cmd" "$cmd.bash"; do
@@ -2554,7 +2557,7 @@ __load_completion()
25542557
done
25552558
done
25562559
2557-
# search deprecated completions "_$cmd"
2560+
# Search fallback completions named "_$cmd"
25582561
for dir in "${dirs[@]}"; do
25592562
[[ -d $dir ]] || continue
25602563
compfile="$dir/_$cmd"
@@ -2564,7 +2567,7 @@ __load_completion()
25642567
# Do not warn with . or .. (especially the former is common)
25652568
[[ $compfile == */.?(.) ]] ||
25662569
echo "bash_completion: $compfile: is a directory" >&2
2567-
elif [[ -e $compfile ]] && . "$compfile"; then
2570+
elif [[ -e $compfile ]] && . "$compfile" "$cmd"; then
25682571
[[ $backslash ]] && $(complete -p "$cmd") "\\$cmd"
25692572
return 0
25702573
fi

completions/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
/host
8585
/hping
8686
/hping3
87+
/_hugo
8788
/iceweasel
8889
/identify
8990
/ifdown
@@ -95,6 +96,7 @@
9596
/iperf3
9697
/javac
9798
/javadoc
99+
/_kn
98100
/kplayer
99101
/l2ping
100102
/lbzip2
@@ -223,12 +225,15 @@
223225
/smbtree
224226
/sparc-koji
225227
/spovray
228+
/_sshi
226229
/star
227230
/stream
228231
/sudoedit
229232
/tightvncviewer
230233
/tracepath6
231234
/typeset
235+
/_upctl
236+
/_vacuum
232237
/vgcfgbackup
233238
/vgcfgrestore
234239
/vgchange

completions/Makefile.am

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ bashcomp_DATA = 2to3 \
3838
bzip2 \
3939
_cal \
4040
cancel \
41+
_cargo \
4142
cardctl \
4243
carton \
4344
ccache \
@@ -130,12 +131,14 @@ bashcomp_DATA = 2to3 \
130131
geoiplookup \
131132
getconf \
132133
getent \
134+
_gh \
133135
gkrellm \
134136
gm \
135137
gnatmake \
136138
gnokii \
137139
gnome-mplayer \
138140
gnome-screenshot \
141+
_golangci-lint \
139142
gpasswd \
140143
gpg \
141144
gpg2 \
@@ -373,7 +376,9 @@ bashcomp_DATA = 2to3 \
373376
rrdtool \
374377
rsync \
375378
_rtcwake \
379+
_ruff \
376380
_runuser \
381+
_rustup \
377382
sbcl \
378383
sbopkg \
379384
screen \
@@ -475,6 +480,7 @@ bashcomp_DATA = 2to3 \
475480
xz \
476481
xzdec \
477482
ypmatch \
483+
_yq \
478484
_yum \
479485
yum-arch \
480486
zopfli \
@@ -593,6 +599,7 @@ CLEANFILES = \
593599
host \
594600
hping \
595601
hping3 \
602+
_hugo \
596603
iceweasel \
597604
identify \
598605
ifdown \
@@ -604,6 +611,7 @@ CLEANFILES = \
604611
iperf3 \
605612
javac \
606613
javadoc \
614+
_kn \
607615
kplayer \
608616
l2ping \
609617
lbzip2 \
@@ -766,12 +774,15 @@ CLEANFILES = \
766774
smbtree \
767775
sparc-koji \
768776
spovray \
777+
_sshi \
769778
star \
770779
stream \
771780
sudoedit \
772781
tightvncviewer \
773782
tracepath6 \
774783
typeset \
784+
_upctl \
785+
_vacuum \
775786
vgcfgbackup \
776787
vgcfgrestore \
777788
vgchange \
@@ -868,6 +879,8 @@ symlinks: $(DATA)
868879
geoiplookup6
869880
$(ss) gkrellm \
870881
gkrellm2
882+
$(ss) _golangci-lint \
883+
_hugo _kn _sshi _upctl _vacuum
871884
$(ss) gpgv \
872885
gpgv2
873886
$(ss) gssdp-discover \

completions/_cargo

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 3rd party completion loader for cargo -*- shell-script -*-
2+
#
3+
# This serves as a fallback in case the completion is not installed otherwise.
4+
5+
# shellcheck disable=SC2168 # "local" is ok, assume sourced by __load_completion
6+
local rustup="${1%cargo}rustup" # use rustup from same dir
7+
eval -- "$("$rustup" completions bash cargo 2>/dev/null)"
8+
9+
{
10+
complete -p "$1" || complete -p "${1##*/}"
11+
} &>/dev/null
12+
13+
# ex: filetype=sh

completions/_gh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "$cmd completion --shell bash".
3+
#
4+
# This serves as a fallback in case the completion is not installed otherwise.
5+
6+
eval -- "$("$1" completion --shell bash 2>/dev/null)"
7+
8+
{
9+
complete -p "$1" || complete -p "${1##*/}"
10+
} &>/dev/null
11+
12+
# ex: filetype=sh

completions/_golangci-lint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "$cmd completion bash".
3+
# For example, many Go programs using https://github.com/spf13/cobra do.
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+
{
10+
complete -p "$1" || complete -p "${1##*/}"
11+
} &>/dev/null
12+
13+
# ex: filetype=sh

completions/_ruff

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "$cmd generate-shell-completion bash".
3+
#
4+
# This serves as a fallback in case the completion is not installed otherwise.
5+
6+
eval -- "$("$1" generate-shell-completion bash 2>/dev/null)"
7+
8+
{
9+
complete -p "$1" || complete -p "${1##*/}"
10+
} &>/dev/null
11+
12+
# ex: filetype=sh

completions/_rustup

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 3rd party completion loader for rustup -*- shell-script -*-
2+
#
3+
# This serves as a fallback in case the completion is not installed otherwise.
4+
5+
eval -- "$("$1" completions bash rustup 2>/dev/null)"
6+
7+
{
8+
complete -p "$1" || complete -p "${1##*/}"
9+
} &>/dev/null
10+
11+
# ex: filetype=sh

completions/_yq

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 3rd party completion loader for commands emitting -*- shell-script -*-
2+
# their completion using "$cmd shell-completion bash".
3+
#
4+
# This serves as a fallback in case the completion is not installed otherwise.
5+
6+
eval -- "$("$1" shell-completion bash 2>/dev/null)"
7+
8+
{
9+
complete -p "$1" || complete -p "${1##*/}"
10+
} &>/dev/null
11+
12+
# ex: filetype=sh

0 commit comments

Comments
 (0)