Sent attached.
El Thu, 8 Jan 2015 21:40:07 +0100 Carlos Morata Castillo escribió: >Hi, > >*Autocompletion for dirs, doesn't leave until you press space. >*Added tmpfs, volatile and network-macvlan options. > >I tried with the SELinux options with seinfo(setools-console), but too >messy to get it right. Even Daniel Walsh haven't done it yet. :) > > >diff --git a/shell-completion/bash/systemd-nspawn >b/shell-completion/bash/systemd-nspawn index f911d1b..8519b7a 100644 >--- a/shell-completion/bash/systemd-nspawn >+++ b/shell-completion/bash/systemd-nspawn >@@ -34,6 +34,20 @@ __get_slices() { > systemctl list-units -t slice --no-legend --no-pager | { while >read a b; do echo " $a"; done; }; } > >+__get_machines() { >+ local a b >+ machinectl list --no-legend --no-pager | { while read a b; do >echo " $a"; done; }; +} >+ >+__get_env() { >+ local a >+ env | { while read a; do echo " ${a%%=*}"; done; }; >+} >+ >+__get_interfaces(){ >+ cut -f 1 -d ' ' /proc/net/dev | tail -n +3 | tr -s '\n' | tr -d >':' | xargs +} >+ > _systemd_nspawn() { > local cur=${COMP_WORDS[COMP_CWORD]} >prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps >@@ -42,7 +56,8 @@ _systemd_nspawn() { > [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' >+ --personality -i --image --tmpfs >--volatile >+ --network-macvlan' > ) > > _init_completion || return >@@ -50,7 +65,8 @@ _systemd_nspawn() { > if __contains_word "$prev" ${OPTS[ARG]}; then > case $prev in > --directory|-D) >- comps=$(compgen -A directory -- "$cur" >) >+ compopt -o nospace >+ comps=$(compgen -S/ -A directory -- >"$cur" ) ;; > --user|-u) > comps=$( __get_users ) >@@ -72,16 +88,21 @@ _systemd_nspawn() { > comps='no auto guest host' > ;; > --bind|--bind-ro) >- comps='' >+ compopt -o nospace >+ comps=$(compgen -S/ -A directory -- >"$cur" ) >+ ;; >+ --tmpfs) >+ compopt -o nospace >+ comps=$(compgen -S/ -A directory -- >"$cur" ) ;; > --machine|-M) >- comps='' >+ comps=$( __get_machines ) > ;; > --slice|-S) > comps=$( __get_slices ) > ;; > --setenv) >- comps='' >+ comps=$( __get_env ) > ;; > --selinux-context|-Z) > comps='' >@@ -93,15 +114,22 @@ _systemd_nspawn() { > comps='yes no' > ;; > --network-interface) >- comps='' >+ comps=$(__get_interfaces) > ;; > --network-bridge) > comps='' > ;; >+ --network-macvlan) >+ comps='' >+ ;; > --personality) > comps='x86 x86-64' > ;; >+ --volatile) >+ comps='yes state no' >+ ;; > --image|-i) >+ compopt -o nospace > comps=$( compgen -A file -- "$cur" ) > ;; > esac
--- shell-completion/bash/systemd-nspawn | 42 ++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/shell-completion/bash/systemd-nspawn b/shell-completion/bash/systemd-nspawn index f911d1b..8519b7a 100644 --- a/shell-completion/bash/systemd-nspawn +++ b/shell-completion/bash/systemd-nspawn @@ -34,6 +34,20 @@ __get_slices() { systemctl list-units -t slice --no-legend --no-pager | { while read a b; do echo " $a"; done; }; } +__get_machines() { + local a b + machinectl list --no-legend --no-pager | { while read a b; do echo " $a"; done; }; +} + +__get_env() { + local a + env | { while read a; do echo " ${a%%=*}"; done; }; +} + +__get_interfaces(){ + cut -f 1 -d ' ' /proc/net/dev | tail -n +3 | tr -s '\n' | tr -d ':' | xargs +} + _systemd_nspawn() { local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local i verb comps @@ -42,7 +56,8 @@ _systemd_nspawn() { [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' + --personality -i --image --tmpfs --volatile + --network-macvlan' ) _init_completion || return @@ -50,7 +65,8 @@ _systemd_nspawn() { if __contains_word "$prev" ${OPTS[ARG]}; then case $prev in --directory|-D) - comps=$(compgen -A directory -- "$cur" ) + compopt -o nospace + comps=$(compgen -S/ -A directory -- "$cur" ) ;; --user|-u) comps=$( __get_users ) @@ -72,16 +88,21 @@ _systemd_nspawn() { comps='no auto guest host' ;; --bind|--bind-ro) - comps='' + compopt -o nospace + comps=$(compgen -S/ -A directory -- "$cur" ) + ;; + --tmpfs) + compopt -o nospace + comps=$(compgen -S/ -A directory -- "$cur" ) ;; --machine|-M) - comps='' + comps=$( __get_machines ) ;; --slice|-S) comps=$( __get_slices ) ;; --setenv) - comps='' + comps=$( __get_env ) ;; --selinux-context|-Z) comps='' @@ -93,15 +114,22 @@ _systemd_nspawn() { comps='yes no' ;; --network-interface) - comps='' + comps=$(__get_interfaces) ;; --network-bridge) comps='' ;; + --network-macvlan) + comps='' + ;; --personality) comps='x86 x86-64' ;; + --volatile) + comps='yes state no' + ;; --image|-i) + compopt -o nospace comps=$( compgen -A file -- "$cur" ) ;; esac @@ -112,4 +140,4 @@ _systemd_nspawn() { COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") ) } -complete -F _systemd_nspawn systemd-nspawn +complete -F _systemd_nspawn systemd_nspawn -- 2.1.0
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel