mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-13 02:07:12 +00:00

This adds a basic bash auto-completion profile. It supports 3 things at this time: - Auto-complete of container name (-n or -o) - Auto-complete of template name (-t) - Auto-complete of state names (-s) It's configured in a way to be as little disruptive as possible, any argument that's not explicitly handled by the profile will fallack to bash's default completion. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
106 lines
2.4 KiB
Bash
106 lines
2.4 KiB
Bash
#!bash
|
|
|
|
have lxc-start && {
|
|
_lxc_names() {
|
|
COMPREPLY=( $( compgen -W "$( lxc-ls )" "$cur" ) )
|
|
}
|
|
|
|
_lxc_states() {
|
|
COMPREPLY=( $( compgen -W "STOPPED STARTING RUNNING STOPPING ABORTING FREEZING FROZEN THAWED" "$cur" ) )
|
|
}
|
|
|
|
_lxc_templates() {
|
|
COMPREPLY=( $( compgen -W "$(ls @LXCTEMPLATEDIR@/ | sed -e 's|^lxc-||' )" "$cur" ) )
|
|
}
|
|
|
|
_lxc-generic-n() {
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
case $prev in
|
|
-n)
|
|
_lxc_names "$cur"
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
return 1
|
|
}
|
|
|
|
_lxc-generic-ns() {
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
case $prev in
|
|
-n)
|
|
_lxc_names "$cur"
|
|
return 0
|
|
;;
|
|
|
|
-s)
|
|
_lxc_states "$cur"
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
return 1
|
|
}
|
|
|
|
_lxc-generic-t() {
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
case $prev in
|
|
-t)
|
|
_lxc_templates "$cur"
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
return 1
|
|
}
|
|
|
|
_lxc-generic-o() {
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
case $prev in
|
|
-o)
|
|
_lxc_names "$cur"
|
|
return 0
|
|
;;
|
|
esac
|
|
|
|
return 1
|
|
}
|
|
|
|
complete -o default -F _lxc-generic-n lxc-attach
|
|
complete -o default -F _lxc-generic-n lxc-cgroup
|
|
complete -o default -F _lxc-generic-n lxc-console
|
|
complete -o default -F _lxc-generic-n lxc-destroy
|
|
complete -o default -F _lxc-generic-n lxc-device
|
|
complete -o default -F _lxc-generic-n lxc-execute
|
|
complete -o default -F _lxc-generic-n lxc-freeze
|
|
complete -o default -F _lxc-generic-n lxc-info
|
|
complete -o default -F _lxc-generic-n lxc-monitor
|
|
complete -o default -F _lxc-generic-n lxc-snapshot
|
|
complete -o default -F _lxc-generic-n lxc-start
|
|
complete -o default -F _lxc-generic-n lxc-stop
|
|
complete -o default -F _lxc-generic-n lxc-unfreeze
|
|
|
|
complete -o default -F _lxc-generic-ns lxc-wait
|
|
|
|
complete -o default -F _lxc-generic-t lxc-create
|
|
|
|
complete -o default -F _lxc-generic-o lxc-clone
|
|
complete -o default -F _lxc-generic-o lxc-start-ephemeral
|
|
}
|