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
4 changes: 0 additions & 4 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,9 +44,6 @@
/dcop.bash
/dfutool.bash
/display.bash
/dpkg-deb.bash
/dpkg-query.bash
/dpkg-reconfigure.bash
/dropdb.bash
/dropuser.bash
/edquota.bash
Expand Down
14 changes: 2 additions & 12 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 @@ -83,9 +84,7 @@ cross_platform = 2to3.bash \
dnssec-keygen.bash \
dnsspoof.bash \
dot.bash \
dpkg.bash \
dpkg-source.bash \
dselect.bash \
dpkg-reconfigure.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,9 +536,6 @@ CLEANFILES = \
dcop.bash \
dfutool.bash \
display.bash \
dpkg-deb.bash \
dpkg-query.bash \
dpkg-reconfigure.bash \
dropdb.bash \
dropuser.bash \
edquota.bash \
Expand Down Expand Up @@ -865,8 +859,6 @@ symlinks: $(DATA)
typeset
$(ss) dict \
rdict
$(ss) dpkg \
dpkg-deb dpkg-query dpkg-reconfigure
$(ss) ether-wake \
etherwake
$(ss) filesnarf \
Expand Down Expand Up @@ -1021,8 +1013,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/dpkg-reconfigure.bash

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be named dpkg-reconfigure.bash -- it does not seem to do anything particularly useful when sourced on demand on debconf <TAB>, and on the other hand as it stands, it won't be sourced for dpkg-reconfigure <TAB>. Let's correct the top level comment while at it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to split it up, this was just carried over from what I had locally, and perhaps that was more of a draft at the time, and when I prepared it for submission it just all seemed to be tied together.

For the debconf name, I think I went with project name as grouping, but I see that does not make sense as you point out it would not trigger any auto-loading. Will rename.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# dpkg-reconfigure(1) 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
9 changes: 9 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 Down Expand Up @@ -140,6 +144,8 @@ CLEANFILES = \
dive.bash \
dlv.bash \
docker.bash \
dpkg-deb.bash \
dpkg-query.bash \
dprint.bash \
driftctl.bash \
dyff.bash \
Expand Down Expand Up @@ -318,6 +324,9 @@ symlinks: $(DATA)
mago release-plz
$(ss) cal \
ncal
$(ss) dpkg \
dpkg-deb \
dpkg-query
$(ss) flamegraph \
just \
watchexec
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,13 @@
# bash completion for update-alternatives

# On dpkg-based systems or systems that use an update-alternatives from the
# dpkg code base, use of this file is deprecated. On those systems
# upstream completion is available in dpkg >= 1.23.8, use that instead.
#
# On chkconfig-based systems this completion complements the alternatives.bash
# completion where update-alternatives is a symlink to alternatives. This
# implementation is based on an old dpkg version, and has diverged since then.

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