PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/bash_completion_lib/include/_available_interfaces

http://github.com/brinkman83/bashrc
#! | 19 lines | 17 code | 2 blank | 0 comment | 0 complexity | 48697bf57a68442c1de0e6b1c7c54102 MD5 | raw file
 1# This function completes on all available network interfaces
 2# -a: restrict to active interfaces only
 3# -w: restrict to wireless interfaces only
 4#
 5_available_interfaces()
 6{
 7	local cmd
 8
 9	if [ "${1:-}" = -w ]; then
10		cmd="iwconfig"
11	elif [ "${1:-}" = -a ]; then
12		cmd="ifconfig"
13	else
14		cmd="ifconfig -a"
15	fi
16
17	COMPREPLY=( $( eval $cmd 2>/dev/null | \
18		sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p') )
19}