Commit 0306de4f by Stéphane Graber

Add bash auto completion

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 21384986
SUBDIRS = apparmor etc init templates SUBDIRS = apparmor bash etc init templates
EXTRA_DIST = lxc
if ENABLE_BASH
install-bash:
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d/
$(INSTALL_DATA) lxc $(DESTDIR)$(sysconfdir)/bash_completion.d/
uninstall-bash:
rm -f $(DESTDIR)$(sysconfdir)/bash_completion.d/lxc
rmdir $(DESTDIR)$(sysconfdir)/bash_completion.d/ || :
install-data-local: install-bash
uninstall-local: uninstall-bash
endif
#!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
}
...@@ -385,6 +385,12 @@ AM_COND_IF([ENABLE_LUA], ...@@ -385,6 +385,12 @@ AM_COND_IF([ENABLE_LUA],
[LUA_INSTALL_LMOD=$datadir/lua/$LUA_VERSION]) [LUA_INSTALL_LMOD=$datadir/lua/$LUA_VERSION])
]) ])
# Optional bash integration
AC_ARG_ENABLE([bash],
[AC_HELP_STRING([--enable-bash], [build bash integration [default=yes]])],
[], [enable_bash=yes])
AM_CONDITIONAL([ENABLE_BASH], [test "x$enable_bash" = "xyes"])
# Optional test binaries # Optional test binaries
AC_ARG_ENABLE([tests], AC_ARG_ENABLE([tests],
[AC_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])], [AC_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])],
...@@ -548,6 +554,8 @@ AC_CONFIG_FILES([ ...@@ -548,6 +554,8 @@ AC_CONFIG_FILES([
config/Makefile config/Makefile
config/apparmor/Makefile config/apparmor/Makefile
config/bash/Makefile
config/bash/lxc
config/init/Makefile config/init/Makefile
config/init/sysvinit/Makefile config/init/sysvinit/Makefile
config/init/systemd/Makefile config/init/systemd/Makefile
...@@ -705,6 +713,7 @@ Environment: ...@@ -705,6 +713,7 @@ Environment:
- init script type(s): $init_script - init script type(s): $init_script
- rpath: $enable_rpath - rpath: $enable_rpath
- GnuTLS: $enable_gnutls - GnuTLS: $enable_gnutls
- Bash integration: $enable_bash
Security features: Security features:
- Apparmor: $enable_apparmor - Apparmor: $enable_apparmor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment