summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/bash-completion58
-rwxr-xr-xcontrib/ifplugd.action26
-rw-r--r--contrib/zsh-completion23
3 files changed, 81 insertions, 26 deletions
diff --git a/contrib/bash-completion b/contrib/bash-completion
new file mode 100644
index 0000000..44dd181
--- /dev/null
+++ b/contrib/bash-completion
@@ -0,0 +1,58 @@
+# netcfg completion by Maciej 'macieks' Sitarz <macieks@freesco.pl>
+
+_connected_prfls ()
+{
+ COMPREPLY=( $( compgen -W "$( ls /var/run/network/profiles/ )" -- $cur ) )
+}
+
+_connected_intfs ()
+{
+ COMPREPLY=( $( compgen -W "$( ls /var/run/network/interfaces/)" -- $cur ) )
+}
+
+_netcfg ()
+{
+ local cur prev opts lopts cmds prfls
+
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ opts="-c -d -a -i -h -v"
+ lopts="--help --version"
+ cmds="check-iface down all-down iface-down all-resume all-suspend"
+ prfls="`find /etc/network.d -maxdepth 1 -not -type d -printf '%f\n'`"
+
+ case "${cur}" in
+ --*)
+ COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
+ return 0
+ ;;
+ -*)
+ COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
+ return 0
+ ;;
+ *)
+ if [ $COMP_CWORD -eq 1 ]; then
+ COMPREPLY=( $( compgen -W "${opts} ${lopts} ${cmds} ${prfls}" -- $cur ) )
+ fi
+ ;;
+ esac
+
+ case "${prev}" in
+ -c|check-iface|-i|iface-down)
+ _connected_intfs
+ return 0
+ ;;
+ -d|down)
+ _connected_prfls
+ return 0
+ ;;
+ *)
+ ;;
+ esac
+
+ return 0
+}
+complete -F _netcfg netcfg
+complete -F _netcfg netcfg2
diff --git a/contrib/ifplugd.action b/contrib/ifplugd.action
deleted file mode 100755
index 720b576..0000000
--- a/contrib/ifplugd.action
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# /etc/ifplugd/ifplugd.action script for Arch Linux
-# can replace the one that comes with extra/ifplugd
-
-# . /etc/rc.conf
-# . /etc/rc.d/functions
-
-case "$2" in
- up)
- if [ "${1:0:3}" == eth ]; then
- /usr/bin/netcfg "myethernet" # replace with name of your desired profile
- fi
- ;;
- down)
- /usr/bin/netcfg iface-down "$1"
- /sbin/ifconfig "$1" down # note that we'll return 0 even if the netcfg call failed, e.g. because iface was already down
- # hence no "failure" messages to syslog
- ;;
- *)
- echo "Wrong arguments" > /dev/stderr
- exit 1
- ;;
-esac
-
-# vim: ft=sh ts=4 et sw=4:
diff --git a/contrib/zsh-completion b/contrib/zsh-completion
new file mode 100644
index 0000000..9f74e42
--- /dev/null
+++ b/contrib/zsh-completion
@@ -0,0 +1,23 @@
+#compdef netcfg netcfg2=netcfg
+local -a disp
+
+all_profiles() {
+ _path_files -W "/etc/network.d" -g "*(.)"
+}
+
+up_profiles() {
+ _files -W "/var/run/network/profiles"
+}
+
+up_ifaces() {
+ _files -W "/var/run/network/interfaces"
+}
+
+_arguments -C \
+'(- *)-c[Start specified profile if its interface is not currently up]:Network profile:all_profiles' \
+'(- *)-d[Take specified profile down]:Active profiles:up_profiles' \
+'(- *)-a[Take all active profiles down]' \
+'(- *)-i[Take down profile active on specified interface]:Active interfaces:up_ifaces' \
+'(- *)-r[Disconnect and reconnect specified profile]:Active profiles:up_profiles' \
+'(- *)-u[Start specified profile]:Network profile:all_profiles' \
+'(- *)*:Network profile:all_profiles' \ No newline at end of file