Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions completions-core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/7zzs.bash
/aclocal-1.1[012345678].bash
/alpine.bash
/alternatives.bash
/animate.bash
/apropos.bash
/aptitude-curses.bash
Expand Down Expand Up @@ -45,8 +44,6 @@
/dcop.bash
/dfutool.bash
/display.bash
/dpkg-deb.bash
/dpkg-query.bash
/dpkg-reconfigure.bash
/dropdb.bash
/dropuser.bash
Expand Down
15 changes: 4 additions & 11 deletions completions-core/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cross_platform = 2to3.bash \
acpi.bash \
add_members.bash \
alias.bash \
alternatives.bash \
ant.bash \
apache2ctl.bash \
appdata-validate.bash \
Expand Down Expand Up @@ -74,6 +75,7 @@ cross_platform = 2to3.bash \
cvs.bash \
cvsps.bash \
dd.bash \
debconf.bash \
declare.bash \
deja-dup.bash \
desktop-file-validate.bash \
Expand All @@ -83,9 +85,6 @@ cross_platform = 2to3.bash \
dnssec-keygen.bash \
dnsspoof.bash \
dot.bash \
dpkg.bash \
dpkg-source.bash \
dselect.bash \
dsniff.bash \
dumpdb.bash \
dumpe2fs.bash \
Expand Down Expand Up @@ -399,7 +398,6 @@ cross_platform = 2to3.bash \
unpack200.bash \
unrar.bash \
unshunt.bash \
update-alternatives.bash \
update-rc.d.bash \
upgradepkg.bash \
urlsnarf.bash \
Expand Down Expand Up @@ -490,7 +488,6 @@ CLEANFILES = \
aclocal-1.17.bash \
aclocal-1.18.bash \
alpine.bash \
alternatives.bash \
animate.bash \
apropos.bash \
aptitude-curses.bash \
Expand Down Expand Up @@ -539,8 +536,6 @@ CLEANFILES = \
dcop.bash \
dfutool.bash \
display.bash \
dpkg-deb.bash \
dpkg-query.bash \
dpkg-reconfigure.bash \
dropdb.bash \
dropuser.bash \
Expand Down Expand Up @@ -861,12 +856,12 @@ symlinks: $(DATA)
mogrify montage stream
$(ss) cowsay \
cowthink
$(ss) debconf \
dpkg-reconfigure
$(ss) declare \
typeset
$(ss) dict \
rdict
$(ss) dpkg \
dpkg-deb dpkg-query dpkg-reconfigure
$(ss) ether-wake \
etherwake
$(ss) filesnarf \
Expand Down Expand Up @@ -1021,8 +1016,6 @@ endif
bsdtar gtar star
$(ss) tracepath \
tracepath6
$(ss) update-alternatives \
alternatives
$(ss) vipw \
vigr
$(ss) vncviewer \
Expand Down
95 changes: 95 additions & 0 deletions completions-core/alternatives.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# bash completion for alternatives

_comp_cmd_alternatives__installed()
{
local i admindir
# find the admin dir
for i in alternatives rpm/alternatives; do
[[ -d /var/lib/$i ]] && admindir=/var/lib/$i && break
done
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == --admindir ]]; then
admindir=${words[i + 1]}
break
fi
done
[[ -d $admindir ]] && _comp_compgen_split -- "$(command ls "$admindir")"
}

_comp_cmd_alternatives()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

case $prev in
--altdir | --admindir)
_comp_compgen_filedir -d
return
;;
--help | --usage | --version)
return
;;
esac

local mode="" args i

# find which mode to use and how many real args used so far
for ((i = 1; i < cword; i++)); do
if [[ ${words[i]} == --@(install|remove|auto|display|config|remove-all|set) ]]; then
mode=${words[i]}
args=$((cword - i))
break
fi
done

case ${mode-} in
--install)
case $args in
1 | 3)
_comp_compgen_filedir
;;
2)
_comp_cmd_alternatives__installed
;;
4)
# priority - no completions
;;
*)
case $((args % 4)) in
0 | 2)
_comp_compgen_filedir
;;
1)
_comp_compgen -- -W '--slave'
;;
3)
_comp_cmd_alternatives__installed
;;
esac
;;
esac
;;
--remove | --set)
case $args in
1)
_comp_cmd_alternatives__installed
;;
2)
_comp_compgen_filedir
;;
esac
;;
--auto | --remove-all | --display | --config)
_comp_cmd_alternatives__installed
;;
*)
_comp_compgen_help - <<<"$(LANG=C "$1" --help 2>&1 | command sed '
/usage:/,/^[[:space:]]*$/{
s/^\([[:space:]]*usage:\)\{0,1\}[[:space:]]*[^[:space:]]*alternatives / /
s/^[[:space:]]*\[\(-.*\)\]/ \1/
}
/common options:/,$s/ --/\n --/g')"
;;
esac
} &&
complete -F _comp_cmd_alternatives alternatives
34 changes: 34 additions & 0 deletions completions-core/debconf.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# debconf(1) and related commands completion

_comp_cmd_dpkg_reconfigure()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local opt

local noargopts='!(-*|*[fp]*)'
# shellcheck disable=SC2254
case $prev in
--frontend | -${noargopts}f)
if _comp_expand_glob opt '/usr/share/perl5/Debconf/FrontEnd/*'; then
opt=("${opt[@]##*/}")
opt=("${opt[@]%.pm}")
_comp_compgen -- -W '"${opt[@]}"'
fi
return
;;
--priority | -${noargopts}p)
_comp_compgen -- -W 'low medium high critical'
return
;;
esac

if [[ $cur == -* ]]; then
_comp_compgen -- -W '--frontend --priority --all --unseen-only --help
--showold --force --terse'
else
_comp_compgen -x dpkg installed_packages
fi
} &&
complete -F _comp_cmd_dpkg_reconfigure -o default dpkg-reconfigure
2 changes: 2 additions & 0 deletions completions-fallback/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
/dive.bash
/dlv.bash
/docker.bash
/dpkg-deb.bash
/dpkg-query.bash
/dprint.bash
/driftctl.bash
/dyff.bash
Expand Down
12 changes: 12 additions & 0 deletions completions-fallback/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ cross_platform = adb.bash \
coder.bash \
delta.bash \
dmesg.bash \
dpkg.bash \
dpkg-source.bash \
dselect.bash \
eject.bash \
flamegraph.bash \
gaiacli.bash \
Expand Down Expand Up @@ -63,6 +66,7 @@ cross_platform = adb.bash \
task.bash \
tokio-console.bash \
udevadm.bash \
update-alternatives.bash \
umount.bash \
umount.linux.bash \
uvx.bash \
Expand All @@ -83,6 +87,7 @@ CLEANFILES = \
airflow.bash \
allero.bash \
alp.bash \
alternatives.bash \
ansible.bash \
ansible-config.bash \
ansible-console.bash \
Expand Down Expand Up @@ -140,6 +145,8 @@ CLEANFILES = \
dive.bash \
dlv.bash \
docker.bash \
dpkg-deb.bash \
dpkg-query.bash \
dprint.bash \
driftctl.bash \
dyff.bash \
Expand Down Expand Up @@ -316,6 +323,9 @@ symlinks: $(DATA)
mago release-plz
$(ss) cal \
ncal
$(ss) dpkg \
dpkg-deb \
dpkg-query
$(ss) flamegraph \
just \
watchexec
Expand Down Expand Up @@ -537,6 +547,8 @@ symlinks: $(DATA)
uv
$(ss) sops \
kata-runtime todoist
$(ss) update-alternatives \
alternatives
$(ss) vault \
bao \
consul \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Debian dpkg-source completion

# Use of this file is deprecated. Upstream completion is available in
# dpkg >= 1.23.8, use that instead.

_comp_cmd_dpkg_source()
{
local cur prev words cword comp_args
Expand Down
36 changes: 3 additions & 33 deletions completions-core/dpkg.bash → completions-fallback/dpkg.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# dpkg(1) and related commands completion

# Use of this file is deprecated. Upstream completion is available in
# dpkg >= 1.23.8, use that instead.

# @since 2.12
_comp_xfunc_dpkg_compgen_installed_packages()
{
Expand Down Expand Up @@ -145,36 +148,3 @@ _comp_cmd_dpkg()
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
} &&
complete -F _comp_cmd_dpkg dpkg dpkg-deb dpkg-query

_comp_cmd_dpkg_reconfigure()
{
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local opt

local noargopts='!(-*|*[fp]*)'
# shellcheck disable=SC2254
case $prev in
--frontend | -${noargopts}f)
if _comp_expand_glob opt '/usr/share/perl5/Debconf/FrontEnd/*'; then
opt=("${opt[@]##*/}")
opt=("${opt[@]%.pm}")
_comp_compgen -- -W '"${opt[@]}"'
fi
return
;;
--priority | -${noargopts}p)
_comp_compgen -- -W 'low medium high critical'
return
;;
esac

if [[ $cur == -* ]]; then
_comp_compgen -- -W '--frontend --priority --all --unseen-only --help
--showold --force --terse'
else
_comp_xfunc_dpkg_compgen_installed_packages
fi
} &&
complete -F _comp_cmd_dpkg_reconfigure -o default dpkg-reconfigure
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Debian Linux dselect(8) completion

# Use of this file is deprecated. Upstream completion is available in
# dpkg >= 1.23.8, use that instead.

_comp_cmd_dselect()
{
local cur prev words cword comp_args
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# bash completion for update-alternatives

# Use of this file is deprecated. Upstream completion is available in
# dpkg >= 1.23.8, use that instead.

_comp_cmd_update_alternatives__installed()
{
local i admindir
Expand Down Expand Up @@ -92,4 +95,4 @@ _comp_cmd_update_alternatives()
;;
esac
} &&
complete -F _comp_cmd_update_alternatives update-alternatives alternatives
complete -F _comp_cmd_update_alternatives update-alternatives