Skip to content

Commit d27b144

Browse files
committed
feat(ruff): add fallback 3rd party completion loader
1 parent 3c1947b commit d27b144

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ bashcomp_DATA = 2to3 \
375375
rrdtool \
376376
rsync \
377377
_rtcwake \
378+
_ruff \
378379
_runuser \
379380
sbcl \
380381
sbopkg \

completions/_ruff

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
# shellcheck disable=SC2168 # "local" is ok, assume sourced by __load_completion
7+
local _comp__load_3rdparty_reset_shopt=$(shopt -po posix)
8+
set +o posix
9+
10+
. <("$1" generate-shell-completion bash 2>/dev/null)
11+
12+
$_comp__load_3rdparty_reset_shopt
13+
14+
{
15+
complete -p "$1" || complete -p "${1##*/}"
16+
} &>/dev/null
17+
18+
# ex: filetype=sh

test/fallback/completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ EXTRA_DIST = \
2323
reptyr \
2424
rfkill \
2525
rtcwake \
26+
ruff \
2627
runuser \
2728
slackpkg \
2829
su \

test/fallback/completions/ruff

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

0 commit comments

Comments
 (0)