summaryrefslogtreecommitdiffstats
path: root/contrib/bash-completion
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2013-02-01 16:27:42 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2013-02-01 16:27:42 +0100
commit0f7cec5f9569be5eaae46faf8d76f06be7152ddb (patch)
treeb6465a40ef5c348ca03c6e66a507ed2d5fd7101b /contrib/bash-completion
parent4a8465a1f308890c7f54eab8c0a7c270fc0246ed (diff)
downloadnetctl-0f7cec5f9569be5eaae46faf8d76f06be7152ddb.tar.gz
netctl-0f7cec5f9569be5eaae46faf8d76f06be7152ddb.tar.xz
Improve completion
- Add Bash completion for netctl-auto and wifi-menu - Add full (but basic) zsh completion
Diffstat (limited to 'contrib/bash-completion')
-rw-r--r--contrib/bash-completion55
1 files changed, 41 insertions, 14 deletions
diff --git a/contrib/bash-completion b/contrib/bash-completion
index 49f1e6b..4ffcabd 100644
--- a/contrib/bash-completion
+++ b/contrib/bash-completion
@@ -1,30 +1,57 @@
# netctl completion
-_netctl()
+
+_wireless_interfaces()
+{
+ local iface
+
+ for iface in /sys/class/net/*/wireless/; do
+ echo ${iface:15:-10}
+ done
+}
+
+
+_netctl_profiles()
{
- local cur prev prof
+ find -L /etc/network.d -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n"
+}
- cur=${COMP_WORDS[COMP_CWORD]}
- prev=${COMP_WORDS[COMP_CWORD-1]}
- prof=$(find -L /etc/network.d -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n")
+
+_netctl()
+{
+ local cur=${COMP_WORDS[COMP_CWORD]}
case $COMP_CWORD in
1)
- COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable reenable" -- $cur) )
+ COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable reenable" -- "$cur") )
;;
2)
- case $prev in
- start|stop|restart|switch-to|status|enable|disable|reenable)
- mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$prof" -- $cur)
- ;;
- esac
- ;;
- *)
- COMPREPLY=()
+ [[ ${COMP_WORDS[COMP_CWORD-1]} = @(start|stop|restart|switch-to|status|enable|disable|reenable) ]] &&
+ mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$(_netctl_profiles)" -- "$cur")
;;
esac
} &&
complete -F _netctl netctl
+_netctl_auto()
+{
+ local cur=${COMP_WORDS[COMP_CWORD]}
+
+ case $COMP_CWORD in
+ 1) COMPREPLY=( $(compgen -W "start stop" -- "$cur") );;
+ 2) COMPREPLY=( $(compgen -W "$(_wireless_interfaces)" -- "$cur") );;
+ esac
+} &&
+complete -F _netctl_auto netctl-auto
+
+
+_wifi_menu()
+{
+ (( COMP_CWORD == 1 )) &&
+ COMPREPLY=( $(compgen -W "$(_wireless_interfaces)" -- "${COMP_WORDS[1]}") )
+} &&
+complete -F _wifi_menu wifi-menu
+
+
# ex: ts=4 sw=4 et filetype=sh