mirror of
https://github.com/systemd/systemd.git
synced 2024-12-14 04:33:37 +08:00
Merge pull request #11147 from yuwata/bash-completion-machinectl
bash-completion: adds import-fs for machinectl and suggest more
This commit is contained in:
commit
57db447ebf
@ -38,7 +38,7 @@ _journalctl() {
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-a --all --full --system --user
|
||||
--disk-usage -f --follow --header
|
||||
-h --help -l --local --new-id128 -m --merge --no-pager
|
||||
-h --help -l --local -m --merge --no-pager
|
||||
--no-tail -q --quiet --setup-keys --verify
|
||||
--version --list-catalog --update-catalog --list-boots
|
||||
--show-cursor --dmesg -k --pager-end -e -r --reverse
|
||||
@ -66,7 +66,7 @@ _journalctl() {
|
||||
compopt -o filenames
|
||||
;;
|
||||
--output|-o)
|
||||
comps='short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json json-pretty json-sse json-seq cat with-unit'
|
||||
comps=$( journalctl --output=help 2>/dev/null )
|
||||
;;
|
||||
--field|-F)
|
||||
comps=$(journalctl --fields | sort 2>/dev/null)
|
||||
|
@ -29,6 +29,12 @@ __get_all_sessions () { loginctl --no-legend list-sessions | { while read -r a b
|
||||
__get_all_users () { loginctl --no-legend list-users | { while read -r a b; do printf "%s\n" "$b"; done; } ; }
|
||||
__get_all_seats () { loginctl --no-legend list-seats | { while read -r a b; do printf "%s\n" "$a"; done; } ; }
|
||||
|
||||
__get_machines() {
|
||||
local a b
|
||||
machinectl list --no-legend --no-pager 2>/dev/null |
|
||||
{ while read a b; do echo " $a"; done; };
|
||||
}
|
||||
|
||||
_loginctl () {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local i verb comps
|
||||
@ -52,9 +58,15 @@ _loginctl () {
|
||||
--host|-H)
|
||||
comps=$(compgen -A hostname)
|
||||
;;
|
||||
--machine|-M)
|
||||
comps=$( __get_machines )
|
||||
;;
|
||||
--property|-p)
|
||||
comps=''
|
||||
;;
|
||||
--output|-o)
|
||||
comps=$( loginctl --output=help 2>/dev/null )
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
|
@ -42,7 +42,7 @@ _machinectl() {
|
||||
)
|
||||
|
||||
local -A VERBS=(
|
||||
[STANDALONE]='list list-images clean pull-tar pull-raw list-transfers cancel-transfer'
|
||||
[STANDALONE]='list list-images clean pull-tar pull-raw list-transfers cancel-transfer import-fs'
|
||||
[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'
|
||||
@ -77,7 +77,13 @@ _machinectl() {
|
||||
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 json-seq cat with-unit'
|
||||
comps=$( machinectl --output=help 2>/dev/null )
|
||||
;;
|
||||
--verify)
|
||||
comps=$( machinectl --verify=help 2>/dev/null )
|
||||
;;
|
||||
--format)
|
||||
comps='uncompressed xz gzip bzip2'
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
|
@ -168,8 +168,7 @@ _systemctl () {
|
||||
comps='full enable-only disable-only'
|
||||
;;
|
||||
--output|-o)
|
||||
comps='short short-full short-iso short-iso-precise short-precise short-monotonic short-unix verbose export json
|
||||
json-pretty json-sse json-seq cat with-unit'
|
||||
comps=$( systemctl --output=help 2>/dev/null )
|
||||
;;
|
||||
--machine|-M)
|
||||
comps=$( __get_machines )
|
||||
|
@ -44,13 +44,20 @@ __get_env() {
|
||||
env | { while read a; do echo " ${a%%=*}"; done; };
|
||||
}
|
||||
|
||||
__get_interfaces(){
|
||||
__get_interfaces() {
|
||||
{ cd /sys/class/net && echo *; } | \
|
||||
while read -d' ' -r name; do
|
||||
[[ "$name" != "lo" ]] && echo "$name"
|
||||
done
|
||||
}
|
||||
|
||||
__get_rlimit() {
|
||||
local i
|
||||
for i in $(systemd-nspawn --rlimit=help 2>/dev/null); do
|
||||
echo " ${i}="
|
||||
done
|
||||
}
|
||||
|
||||
_systemd_nspawn() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local i verb comps
|
||||
@ -62,7 +69,8 @@ _systemd_nspawn() {
|
||||
-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'
|
||||
--network-zone -p --port --system-call-filter --overlay --overlay-ro --settings
|
||||
--rlimit --hostname --no-new-privileges --oom-score-adjust --cpu-affinity --resolv-conf --timezone'
|
||||
)
|
||||
|
||||
_init_completion || return
|
||||
@ -131,7 +139,7 @@ _systemd_nspawn() {
|
||||
comps='x86 x86-64'
|
||||
;;
|
||||
--volatile)
|
||||
comps='yes state no'
|
||||
comps=$( systemd-nspawn --volatile=help 2>/dev/null )
|
||||
;;
|
||||
--image|-i)
|
||||
compopt -o nospace
|
||||
@ -153,6 +161,27 @@ _systemd_nspawn() {
|
||||
--settings)
|
||||
comps='yes no override trusted'
|
||||
;;
|
||||
--rlimit)
|
||||
comps=$( __get_rlimit )
|
||||
;;
|
||||
--hostname)
|
||||
comps=''
|
||||
;;
|
||||
--no-new-privileges)
|
||||
comps='yes no'
|
||||
;;
|
||||
--oom-score-adjust)
|
||||
comps=''
|
||||
;;
|
||||
--cpu-affinity)
|
||||
comps=''
|
||||
;;
|
||||
--resolv-conf)
|
||||
comps=$( systemd-nspawn --resolv-conf=help 2>/dev/null )
|
||||
;;
|
||||
--timezone)
|
||||
comps=$( systemd-nspawn --timezone=help 2>/dev/null )
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
|
@ -36,14 +36,15 @@ _systemd_run() {
|
||||
--on-active --on-boot --on-startup --on-unit-active --on-unit-inactive
|
||||
--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'
|
||||
--no-ask-password --wait -P --pipe -G --collect --working-directory
|
||||
-d --same-dir -S --shell'
|
||||
|
||||
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
|
||||
--path-property --socket-property --uid --gid --nice -E --setenv --working-directory
|
||||
)
|
||||
for (( i=1; i <= COMP_CWORD; i++ )); do
|
||||
if [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
@ -109,6 +110,17 @@ _systemd_run() {
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
--working-directory)
|
||||
local comps
|
||||
if [[ -z $cur ]]; then
|
||||
comps=$(compgen -A directory -- "/" )
|
||||
else
|
||||
comps=$(compgen -A directory -- "$cur" )
|
||||
fi
|
||||
compopt -o filenames
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
||||
|
Loading…
Reference in New Issue
Block a user