blob: d045844cf29457368ba738d98d3da0ea87d6ac37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# netcfg completion by Maciej 'macieks' Sitarz <macieks@freesco.pl>
_connected_prfls ()
{
COMPREPLY=( $( compgen -W "$( ls /run/network/profiles/ )" -- $cur ) )
}
_connected_intfs ()
{
COMPREPLY=( $( compgen -W "$( ls /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="-l -c -u -r -R -d -D -a -v -h"
lopts="--help --version"
cmds="list current check-iface up reconnect iface-recon down iface-down all-down all-suspend"
prfls="`find /etc/network.d -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' 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
-R|iface-recon|-D|iface-down)
_connected_intfs
return 0
;;
-c|check-iface|-u|up|-r|reconnect|-d|down)
_connected_prfls
return 0
;;
*)
;;
esac
return 0
}
complete -F _netcfg netcfg
complete -F _netcfg netcfg2
|