-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_completion
31 lines (31 loc) · 1.07 KB
/
.bash_completion
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
# This function completes on configured network interfaces
#
_configured_interfaces()
{
if [[ -f /etc/debian_version ]]; then
interfaces_d=""
for i in /etc/network/interfaces.d/*; do
if [ -e "$i" ]; then
interfaces_d="$interfaces_d $i"
fi
done
# Debian system
COMPREPLY=( $( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p'\
/etc/network/interfaces $interfaces_d )" -- "$cur" ) )
elif [[ -f /etc/SuSE-release ]]; then
# SuSE system
COMPREPLY=( $( compgen -W "$( printf '%s\n' \
/etc/sysconfig/network/ifcfg-* | \
sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
elif [[ -f /etc/pld-release ]]; then
# PLD Linux
COMPREPLY=( $( compgen -W "$( command ls -B \
/etc/sysconfig/interfaces | \
sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
else
# Assume Red Hat
COMPREPLY=( $( compgen -W "$( printf '%s\n' \
/etc/sysconfig/network-scripts/ifcfg-* | \
sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" ) )
fi
}