Merge pull request #7844 from yuwata/bash-completion

update bash completions
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-01-15 13:51:29 +04:00 committed by GitHub
commit c557fc3e2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 139 additions and 67 deletions

View file

@ -881,7 +881,7 @@
</varlistentry>
<varlistentry>
<term><command>cancel-transfers</command> <replaceable>ID</replaceable></term>
<term><command>cancel-transfer</command> <replaceable>ID</replaceable></term>
<listitem><para>Aborts a download, import or export of the
container or VM image with the specified ID. To list ongoing

View file

@ -398,6 +398,7 @@
</varlistentry>
<varlistentry>
<term><option>-S</option></term>
<term><option>--slice=</option></term>
<listitem><para>Make the container part of the specified slice, instead of the default

View file

@ -170,6 +170,7 @@
</varlistentry>
<varlistentry>
<term><option>-r</option></term>
<term><option>--remain-after-exit</option></term>
<listitem><para>After the service process has terminated, keep the service around until it is explicitly

View file

@ -29,7 +29,8 @@ _bootctl() {
local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-h --help --version'
[STANDALONE]='-h --help --no-variables -p --print-path --version'
[ARG]='--path'
)
if [[ "$cur" = -* ]]; then
@ -38,7 +39,7 @@ _bootctl() {
fi
local -A VERBS=(
[STANDALONE]='status'
[STANDALONE]='help install list remove status update'
)
for ((i=0; i < COMP_CWORD; i++)); do

View file

@ -78,9 +78,10 @@ _busctl() {
local -A OPTS=(
[STANDALONE]='-h --help --version --no-pager --no-legend --system --user
--show-machine --unique --acquired --activatable --list
--quiet --verbose --expect-reply=no --auto-start=no
--allow-interactive-authorization=yes --augment-creds=no'
[ARG]='-H --host -M --machine --address --match --timeout'
-q --quiet --verbose --expect-reply=no --auto-start=no
--allow-interactive-authorization=no --augment-creds=no
--watch-bind=yes'
[ARG]='--address -H --host -M --machine --match --timeout --size'
)
if __contains_word "--user" ${COMP_WORDS[*]}; then

View file

@ -39,22 +39,25 @@ _coredumpctl() {
local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1
-r --reverse -S --since -U --until'
-r --reverse -S --since -U --until -D --directory -q --quiet'
local -A VERBS=(
[LIST]='list'
[LIST]='list info'
[DUMP]='dump gdb'
)
if __contains_word "$prev" '--output -o'; then
comps=$( compgen -A file -- "$cur" )
compopt -o filenames
elif __contains_word "$prev" '--FIELD -F'; then
elif __contains_word "$prev" '-D --directory'; then
comps=$( compgen -A directory -- "$cur" )
compopt -o filenames
elif __contains_word "$prev" '--field -F'; then
comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
elif [[ $cur = -* ]]; then
comps=${OPTS}
elif __contains_word "$prev" ${VERBS[*]} &&
! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -F --field'; then
! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -D --directory -F --field'; then
compopt -o nospace
COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
return 0

View file

@ -29,7 +29,7 @@ _hostnamectl() {
local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --transient --static --pretty
--no-ask-password -H --host --machine'
--no-ask-password -H --host -M --machine'
if [[ $cur = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )

View file

@ -39,25 +39,25 @@ _journalctl() {
[STANDALONE]='-a --all --full --system --user
--disk-usage -f --follow --header
-h --help -l --local --new-id128 -m --merge --no-pager
--no-tail -q --quiet --setup-keys --this-boot --verify
--no-tail -q --quiet --setup-keys --verify
--version --list-catalog --update-catalog --list-boots
--show-cursor --dmesg -k --pager-end -e -r --reverse
--utc -x --catalog --no-full --force --dump-catalog
--flush --rotate --sync --no-hostname'
[ARG]='-b --boot --this-boot -D --directory --file -F --field
--flush --rotate --sync --no-hostname -N --fields'
[ARG]='-b --boot -D --directory --file -F --field -t --identifier
-M --machine -o --output -u --unit --user-unit -p --priority
--vacuum-size --vacuum-time --vacuum-files'
[ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until
--after-cursor --verify-key -t --identifier
--root'
[ARGUNKNOWN]='-c --cursor --interval -n --lines -S --since -U --until
--after-cursor --verify-key
--vacuum-size --vacuum-time --vacuum-files --output-fields'
)
if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then
case $prev in
--boot|--this-boot|-b)
--boot|-b)
comps=$(journalctl -F '_BOOT_ID' 2>/dev/null)
;;
--directory|-D)
--directory|-D|--root)
comps=$(compgen -d -- "$cur")
compopt -o filenames
;;
@ -66,7 +66,7 @@ _journalctl() {
compopt -o filenames
;;
--output|-o)
comps='short short-full short-iso short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat'
comps='short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat'
;;
--field|-F)
comps=$(journalctl --fields | sort 2>/dev/null)

View file

@ -38,7 +38,7 @@ _kernel_install() {
fi
;;
3)
[[ "$cur" ]] || cur=/boot/vmlinuz-${COMP_WORDS[2]}
[[ "$cur" ]] || cur=/lib/modules/${COMP_WORDS[2]}/vmlinuz
comps=$(compgen -f -- "$cur")
compopt -o filenames
;;

View file

@ -35,7 +35,7 @@ _localectl() {
local i verb comps locale_vals
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --no-convert --no-pager --no-ask-password
-H --host --machine'
-H --host -M --machine'
if __contains_word "$prev" $OPTS; then
case $prev in
@ -53,10 +53,11 @@ _localectl() {
fi
local -A VERBS=(
[STANDALONE]='status list-locales list-keymaps'
[LOCALES]='set-locale'
[KEYMAPS]='set-keymap'
[X11]='set-x11-keymap'
[STANDALONE]='status list-locales list-keymaps list-x11-keymap-models list-x11-keymap-layouts list-x11-keymap-options'
[VARIANTS]='list-x11-keymap-variants'
[LOCALES]='set-locale'
[KEYMAPS]='set-keymap'
[X11]='set-x11-keymap'
)
for ((i=0; i < COMP_CWORD; i++)); do
@ -68,6 +69,8 @@ _localectl() {
if [[ -z $verb ]]; then
comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[VARIANTS]}; then
comps=$(command localectl list-x11-keymap-layouts)
elif __contains_word "$verb" ${VERBS[LOCALES]}; then
if [[ $cur = *=* ]]; then
mapfile -t locale_vals < <(command localectl list-locales 2>/dev/null)

View file

@ -34,10 +34,11 @@ _loginctl () {
local i verb comps
local -A OPTS=(
[STANDALONE]='--all -a --help -h --no-pager --privileged -P --version
--no-legend --no-ask-password -l --full'
[ARG]='--host -H --kill-who --property -p --signal -s --machine'
)
[STANDALONE]='--all -a --help -h --no-pager --version
--no-legend --no-ask-password -l --full --value'
[ARG]='--host -H --kill-who --property -p --signal -s -M --machine
-n --lines -o --output'
)
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
@ -69,7 +70,7 @@ _loginctl () {
[SESSIONS]='session-status show-session activate lock-session unlock-session terminate-session kill-session'
[USERS]='user-status show-user enable-linger disable-linger terminate-user kill-user'
[SEATS]='seat-status show-seat terminate-seat'
[STANDALONE]='list-sessions list-users list-seats flush-devices'
[STANDALONE]='list-sessions lock-sessions unlock-sessions list-users list-seats flush-devices'
[ATTACH]='attach'
)

View file

@ -36,13 +36,17 @@ _machinectl() {
local i verb comps
local -A OPTS=(
[STANDALONE]='--all -a --full --help -h --no-ask-password --no-legend --no-pager --version'
[ARG]='--host -H --kill-who -M --machine --property -p --signal -s'
[STANDALONE]='--all -a -l --full --help -h --no-ask-password --no-legend --no-pager --version --value
--mkdir --read-only --force -q --quiet'
[ARG]='--host -H --kill-who -M --machine --property -p --signal -s --uid -E --setenv -n --lines
-o --output --verify --format --max-addresses'
)
local -A VERBS=(
[STANDALONE]='list list-images pull-tar pull-raw import-tar import-raw export-tar export-raw list-transfers cancel-transfer'
[MACHINES]='status show start stop login shell enable disable poweroff reboot terminate kill copy-to copy-from image-status show-image clone rename read-only remove set-limit'
[STANDALONE]='list list-images clean pull-tar pull-raw list-transfers cancel-transfer'
[MACHINES]='status show start stop login shell enable disable poweroff reboot terminate kill bind copy-to copy-from
image-status show-image clone rename read-only remove set-limit export-tar export-raw'
[FILE]='import-tar import-raw'
)
_init_completion || return
@ -73,6 +77,9 @@ _machinectl() {
--property|-p)
comps=''
;;
--output|-o)
comps='short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json json-pretty json-sse cat'
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
@ -91,6 +98,10 @@ _machinectl() {
elif __contains_word "$verb" ${VERBS[MACHINES]}; then
comps=$( __get_machines )
elif __contains_word "$verb" ${VERBS[FILE]}; then
comps=$(compgen -f -- "cur")
compopt -o filenames
fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )

View file

@ -37,8 +37,8 @@ _networkctl() {
)
local -A VERBS=(
[STANDALONE]='list lldp label'
[LINKS]='status'
[STANDALONE]='label'
[LINKS]='status list lldp'
)
_init_completion || return

View file

@ -126,10 +126,10 @@ _systemctl () {
local -A OPTS=(
[STANDALONE]='--all -a --reverse --after --before --defaults --force -f --full -l --global
--help -h --no-ask-password --no-block --no-legend --no-pager --no-reload --no-wall --now
--quiet -q --privileged -P --system --user --version --runtime --recursive -r --firmware-setup
--show-types -i --ignore-inhibitors --plain --failed'
--quiet -q --system --user --version --runtime --recursive -r --firmware-setup
--show-types -i --ignore-inhibitors --plain --failed --value --fail --dry-run --wait'
[ARG]='--host -H --kill-who --property -p --signal -s --type -t --state --job-mode --root
--preset-mode -n --lines -o --output -M --machine'
--preset-mode -n --lines -o --output -M --machine --message'
)
if __contains_word "--user" ${COMP_WORDS[*]}; then
@ -203,14 +203,15 @@ _systemctl () {
[TARGET_AND_UNITS]='add-wants add-requires'
[MASKED_UNITS]='unmask'
[JOBS]='cancel'
[ENVS]='set-environment unset-environment'
[ENVS]='set-environment unset-environment import-environment'
[STANDALONE]='daemon-reexec daemon-reload default
emergency exit halt hibernate hybrid-sleep kexec list-jobs
list-sockets list-timers list-units list-unit-files poweroff
reboot rescue show-environment suspend get-default
is-system-running'
is-system-running preset-all'
[FILE]='link switch-root'
[TARGETS]='set-default'
[MACHINES]='list-machines'
)
for ((i=0; i < COMP_CWORD; i++)); do
@ -294,12 +295,13 @@ _systemctl () {
elif __contains_word "$verb" ${VERBS[ENVS]}; then
comps=$( __systemctl $mode show-environment \
| while read -r line; do echo " ${line%%=*}=";done )
| while read -r line; do echo " ${line%%=*}="; done )
compopt -o nospace
elif __contains_word "$verb" ${VERBS[FILE]}; then
comps=$( compgen -A file -- "$cur" )
compopt -o filenames
elif __contains_word "$verb" ${VERBS[TARGETS]}; then
comps=$( __systemctl $mode list-unit-files --type target --full --all \
| { while read -r a b; do echo " $a"; done; } )

View file

@ -36,12 +36,13 @@ _systemd_analyze() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='--help --version --system --user --order --require --no-pager --man'
[ARG]='-H --host -M --machine --fuzz --from-pattern --to-pattern '
[STANDALONE]='-h --help --version --system --user --order --require --no-pager
--man=no --generators=yes'
[ARG]='-H --host -M --machine --fuzz --from-pattern --to-pattern'
)
local -A VERBS=(
[STANDALONE]='time blame plot dump get-log-level get-log-target'
[STANDALONE]='time blame plot dump get-log-level get-log-target calendar'
[CRITICAL_CHAIN]='critical-chain'
[DOT]='dot'
[LOG_LEVEL]='set-log-level'
@ -117,7 +118,7 @@ _systemd_analyze() {
elif __contains_word "$verb" ${VERBS[VERIFY]}; then
if [[ $cur = -* ]]; then
comps='--help --version --system --user --man'
comps='--help --version --system --user --man=no --generators=yes'
else
comps=$( compgen -A file -- "$cur" )
compopt -o filenames

View file

@ -30,13 +30,21 @@ __get_machines() {
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
}
__get_units_have_cgroup() {
systemctl $1 list-units | {
while read -r a b c d; do
[[ $c == "active" && ${a##*.} =~ (service|socket|mount|swap|slice|scope) ]] && echo " $a"
done
};
}
_systemd_cgls() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local i verb comps
local -A OPTS=(
[STANDALONE]='-h --help --version --all -l --full -k --no-pager'
[ARG]='-M --machine'
[ARG]='-M --machine -u --unit --user-unit'
)
_init_completion || return
@ -46,6 +54,12 @@ _systemd_cgls() {
--machine|-M)
comps=$( __get_machines )
;;
--unit|-u)
comps=$( __get_units_have_cgroup --system )
;;
--user-unit)
comps=$( __get_units_have_cgroup --user )
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0

View file

@ -30,7 +30,8 @@ _systemd_detect_virt() {
local i verb comps
local -A OPTS=(
[STANDALONE]='-h --help --version -c --container -v --vm -q --quiet'
[STANDALONE]='-h --help --version -c --container -v --vm -q --quiet
--private-users'
)
_init_completion || return

View file

@ -57,12 +57,13 @@ _systemd_nspawn() {
local i verb comps
local -A OPTS=(
[STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit --network-veth -j'
[ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
-S --slice --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
--personality -i --image --tmpfs --volatile
--network-macvlan --kill-signal --template
--notify-ready'
[STANDALONE]='-h --help --version --private-network -b --boot --read-only -q --quiet --share-system --keep-unit -n --network-veth
-j -x --ephemeral -a --as-pid2 --private-users-chown -U'
[ARG]='-D --directory -u --user --uuid --capability --drop-capability --link-journal --bind --bind-ro -M --machine
-S --slice -E --setenv -Z --selinux-context -L --selinux-apifs-context --register --network-interface --network-bridge
--personality -i --image --tmpfs --volatile --network-macvlan --kill-signal --template --notify-ready --root-hash
--chdir --pivot-root --property --private-users --network-namespace-path --network-ipvlan --network-veth-extra
--network-zone -p --port --system-call-filter --overlay --overlay-ro --settings'
)
_init_completion || return
@ -76,7 +77,7 @@ _systemd_nspawn() {
--user|-u)
comps=$( __get_users )
;;
--uuid)
--uuid|--root-hash)
comps=''
;;
--capability)
@ -106,7 +107,7 @@ _systemd_nspawn() {
--slice|-S)
comps=$( __get_slices )
;;
--setenv)
--setenv|-E)
comps=$( __get_env )
;;
--selinux-context|-Z)
@ -143,7 +144,15 @@ _systemd_nspawn() {
;;
--notify-ready)
comps='yes no'
return
;;
--private-users)
comps='yes no pick'
;;
--network-namespace-path)
comps=$( compgen -A file -- "$cur" )
;;
--settings)
comps='yes no override trusted'
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )

View file

@ -36,11 +36,13 @@ _systemd-resolve() {
local i comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-h --help --version -4 -6
[STANDALONE]='-h --help --version --no-pager -4 -6
--service --openpgp --tlsa --status --statistics
--reset-statistics --service-address=no --service-txt=no
--cname=no --search=no --legend=no'
[ARG]='-i --interface -p --protocol -t --type -c --class'
--cname=no --search=no --legend=no --flush-caches
--reset-server-features --revert'
[ARG]='-i --interface -p --protocol -t --type -c --class --raw
--set-dns --set-domain --set-llmnr --set-mdns --set-dnssec --set-nta'
)
if __contains_word "$prev" ${OPTS[ARG]}; then
@ -51,6 +53,18 @@ _systemd-resolve() {
--protocol|-p|--type|-t|--class|-c)
comps=$( systemd-resolve --legend=no "$prev" help; echo help )
;;
--raw)
comps="payload packet"
;;
--set-dns|--set-domain|--set-nta)
comps=""
;;
--set-llmnr|--set-mdns)
comps="yes no resolve"
;;
--set-dnssec)
comps="yes no allow-downgrade"
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0

View file

@ -36,15 +36,16 @@ _systemd_run() {
local OPTS='-h --help --version --user --system --scope --unit --description --slice
-r --remain-after-exit --send-sighup -H --host -M --machine --service-type
--on-active --on-boot --on-startup --on-unit-active --on-unit-inactive
--on-calendar --timer-property -t --pty -q --quiet --no-block
--uid --gid --nice --setenv -p --property --no-ask-password
--wait'
--on-calendar --timer-property --path-property --socket-property -t --pty
-q --quiet --no-block --uid --gid --nice -E --setenv -p --property
--no-ask-password --wait -P --pipe -G --collect'
local mode=--system
local i
local opts_with_values=(
--unit --description --slice --service-type -H --host -M --machine -p --property --on-active
--on-boot --on-startup --on-unit-active --on-unit-inactive --on-calendar --timer-property
--path-property --socket-property --uid --gid --nice -E --setenv
)
for (( i=1; i <= COMP_CWORD; i++ )); do
if [[ ${COMP_WORDS[i]} != -* ]]; then

View file

@ -25,16 +25,24 @@ __contains_word () {
done
}
__get_machines() {
local a b
machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; };
}
_timedatectl() {
local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --adjust-system-clock --no-pager
--no-ask-password -H --host --machine'
--no-ask-password -H --host -M --machine'
if __contains_word "$prev" $OPTS; then
case $prev in
--host|-H)
comps=''
comps=$(compgen -A hostname)
;;
--machine|-M)
comps=$( __get_machines )
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
@ -48,7 +56,7 @@ _timedatectl() {
local -A VERBS=(
[BOOLEAN]='set-local-rtc set-ntp'
[STANDALONE]='status set-time list-timezones'
[STANDALONE]='status list-timezones'
[TIMEZONES]='set-timezone'
[TIME]='set-time'
)