You are not logged in.
Pages: 1
I wrote a small completion addon for zsh/netcfg.
Hope it helps.
#compdef netcfg
local expl list intf sep
local -a disp
case $OSTYPE in
aix*)
intf=( ${(f)"$(lsdev -C -c if -F 'name:description')"} )
if zstyle -T ":completion:${curcontext}" verbose; then
zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
zformat -a list " $sep " "$intf[@]"
disp=(-ld list)
fi
;;
darwin*|freebsd*|dragonfly*) intf=( $(ifconfig -l) ) ;;
irix*) intf=( ${${${(f)"$(/usr/etc/netstat -i)"}%% *}[2,-1]} ) ;;
linux*) intf=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) ) ;;
*) intf=( $(ifconfig -a|sed -n 's/^([^ :]*).*/1/p') ) ;;
esac
_arguments -C
'(--menu --stop --stopall)-c[Dont reconfigure an interface if its already up]:profile:->profilelist'
'(--menu --stopall -c *)--stop[Stops an interface]:interface:->interfaces'
'(-c --stop --stopall *)--menu[Display the menu]:timeout:->menuopt'
'(-c --stop --menu *)--stopall[Stops all interfaces]'
'*:profile:->profilelist'
if [[ "$state" = profilelist ]]; then
_description path_files expl 'Netwok Profiles'
_path_files "$expl[@]" -W '/etc/network-profiles' -g '*~*template'
fi
if [[ "$state" = menuopt ]]; then
_arguments -C
'--timeout:integer'
fi
if [[ "$state" = interfaces ]]; then
_wanted interfaces expl 'network interface' compadd "$@" "$disp[@]" - "${(@)intf%%:*}"
fi
Any resemblance to grammar or spelling mistakes is purely coincidental and independant of the willing of the author
Offline
Definitely useful.
Maybe instead of a zsh-pacman package, we should have a zsh-completion package.
todo add zsh completion package
Offline
Maybe it could be directly integrated into zsh package ?
IMHO, every zsh users use zsh for it's completion facilities and pacman and netcfg are always installed.
It could be a bad idea (why?), but it might be considered.
Any resemblance to grammar or spelling mistakes is purely coincidental and independant of the willing of the author
Offline
2 years later...
I updated this script so that it works with netcfg2. Please be gentle, it's my very first attempt to write a zsh completion function
#compdef netcfg netcfg2=netcfg
local -a disp
_arguments -C \
'(-a -d -i)-c[Do not start profile if interface is already up]' \
'(-a -i)-d[Take specified profile down]:Active profiles:_files -W "/var/run/network/profiles"' \
'(-c -d -i *)-a[Take all active profiles down]' \
'(-a -c -d)-i[Take down profile active on specified interface]:Active interfaces:_files -W "/var/run/network/interfaces"' \
'*:Network profiles:_path_files -W "/etc/network.d" -g "*(.)"'
Hope it helps.
There's no place like ::1
Offline
Offline
Sure ! It's on AUR: http://aur.archlinux.org/packages.php?ID=22300
There's no place like ::1
Offline
Offline
Pages: 1