mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-18 06:10:40 +02:00
cli: update bash-completion file for 'connection add'
* _nmcli_list vs. _nmcli_list_nl - space vs. new-line separated list * connection add - various types, modes, mac, ifname, ...
This commit is contained in:
parent
6c2e7706af
commit
24f05292da
1 changed files with 87 additions and 22 deletions
|
|
@ -7,41 +7,59 @@ _nmcli_list()
|
|||
COMPREPLY=( $( compgen -W '$1' -- $cur ) )
|
||||
}
|
||||
|
||||
_nmcli_con_id()
|
||||
_nmcli_list_nl()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f NAME con show c 2>/dev/null )" -- $cur ) )
|
||||
COMPREPLY=( $( compgen -W '$1' -- $cur ) )
|
||||
}
|
||||
|
||||
_nmcli_con_id()
|
||||
{
|
||||
echo "$(nmcli -t -f NAME con show c 2>/dev/null)"
|
||||
}
|
||||
|
||||
_nmcli_con_uuid()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f UUID con show c 2>/dev/null )" -- $cur ) )
|
||||
echo "$(nmcli -t -f UUID con show c 2>/dev/null)"
|
||||
}
|
||||
|
||||
_nmcli_con_path()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f DBUS-PATH con show c 2>/dev/null )" -- $cur ) )
|
||||
echo "$(nmcli -t -f DBUS-PATH con show c 2>/dev/null)"
|
||||
}
|
||||
|
||||
_nmcli_con_apath()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f DBUS-PATH con show a 2>/dev/null )" -- $cur ) )
|
||||
echo "$(nmcli -t -f DBUS-PATH con show a 2>/dev/null)"
|
||||
}
|
||||
|
||||
_nmcli_ap_ssid()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f SSID dev wifi list 2>/dev/null )" -- $cur ) )
|
||||
echo "$(nmcli -t -f SSID dev wifi list 2>/dev/null)"
|
||||
|
||||
# without quotes
|
||||
#ssids="$(nmcli -t -f SSID dev wifi list 2>/dev/null)"
|
||||
#local IFS=$'\n'
|
||||
#for ssid in $ssids; do
|
||||
# temp="${ssid%\'}"
|
||||
# temp="${temp#\'}"
|
||||
# echo "$temp"
|
||||
#done
|
||||
}
|
||||
|
||||
_nmcli_ab_bssid()
|
||||
_nmcli_ap_bssid()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f BSSID dev wifi list 2>/dev/null )" -- $cur ) )
|
||||
echo "$(nmcli -e no -t -f BSSID dev wifi list 2>/dev/null)"
|
||||
}
|
||||
|
||||
_nmcli_NM_devices()
|
||||
{
|
||||
COMPREPLY=( $( compgen -W "$(nmcli -t -f DEVICE dev status 2>/dev/null )" -- $cur ) )
|
||||
echo "$(nmcli -t -f DEVICE dev status 2>/dev/null)"
|
||||
}
|
||||
|
||||
_nmcli_NM_dev_MAC()
|
||||
{
|
||||
echo "$(nmcli -t dev show | grep HWADDR | cut -d':' -f2- | sort | uniq)"
|
||||
}
|
||||
|
||||
_nmcli()
|
||||
|
|
@ -63,34 +81,77 @@ _nmcli()
|
|||
return 0
|
||||
;;
|
||||
id)
|
||||
_nmcli_con_id
|
||||
_nmcli_list_nl "$(_nmcli_con_id)"
|
||||
return 0
|
||||
;;
|
||||
uuid)
|
||||
_nmcli_con_uuid
|
||||
_nmcli_list_nl "$(_nmcli_con_uuid)"
|
||||
return 0
|
||||
;;
|
||||
path)
|
||||
_nmcli_con_path
|
||||
_nmcli_list_nl "$(_nmcli_con_path)"
|
||||
return 0
|
||||
;;
|
||||
apath)
|
||||
_nmcli_con_apath
|
||||
_nmcli_list_nl "$(_nmcli_con_apath)"
|
||||
return 0
|
||||
;;
|
||||
iface)
|
||||
iface | ifname)
|
||||
#_available_interfaces
|
||||
_nmcli_NM_devices
|
||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||
return 0
|
||||
;;
|
||||
bssid)
|
||||
_nmcli_ab_bssid
|
||||
_nmcli_list_nl "$(_nmcli_ap_bssid)"
|
||||
return 0
|
||||
;;
|
||||
wep-key-type)
|
||||
_nmcli_list "key phrase"
|
||||
return 0
|
||||
;;
|
||||
autoconnect | stp | hairpin)
|
||||
_nmcli_list "yes no"
|
||||
return 0
|
||||
;;
|
||||
# connection types
|
||||
type)
|
||||
_nmcli_list "ethernet wifi wimax gsm cdma infiniband adsl bluetooth vpn \
|
||||
olpc-mesh vlan bond bridge bond-slave bridge-slave"
|
||||
return 0
|
||||
;;
|
||||
# VPN types
|
||||
vpn-type)
|
||||
_nmcli_list "vpn-type vpnc openvpn pptp openconnect openswan"
|
||||
return 0
|
||||
;;
|
||||
# Bluetooth modes
|
||||
bt-type)
|
||||
_nmcli_list "panu dun-gsm dun-cdma"
|
||||
return 0
|
||||
;;
|
||||
# InfiniBand transport modes
|
||||
transport-mode)
|
||||
_nmcli_list "datagram connected"
|
||||
return 0
|
||||
;;
|
||||
# bonding modes
|
||||
mode)
|
||||
_nmcli_list "balance-rr active-backup balance-xor broadcast \
|
||||
802.3ad balance-tlb balance-alb"
|
||||
return 0
|
||||
;;
|
||||
# MAC addresses
|
||||
mac)
|
||||
_mac_addresses
|
||||
return 0
|
||||
;;
|
||||
# master interface
|
||||
master)
|
||||
UUIDS=$(_nmcli_con_uuid)
|
||||
DEVICES=$(_nmcli_NM_devices)
|
||||
_nmcli_list "$DEVICES $UUIDS"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ $cword -eq 1 ]] ; then
|
||||
|
|
@ -175,26 +236,30 @@ _nmcli()
|
|||
_nmcli_list "id uuid path apath"
|
||||
return 0
|
||||
;;
|
||||
add)
|
||||
_nmcli_list "type con-name autoconnect ifname help"
|
||||
return 0
|
||||
;;
|
||||
delete)
|
||||
_nmcli_list "id uuid path"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
_nmcli_list "show up down delete help"
|
||||
_nmcli_list "show up down add delete help"
|
||||
;;
|
||||
|
||||
device)
|
||||
case $command in
|
||||
show)
|
||||
_nmcli_NM_devices
|
||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||
return 0
|
||||
;;
|
||||
disconnect)
|
||||
if [[ "$cur" == -* ]]; then
|
||||
_nmcli_list "--nowait --timeout"
|
||||
else
|
||||
_nmcli_NM_devices
|
||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
|
|
@ -211,7 +276,7 @@ _nmcli()
|
|||
_nmcli_list "--private --nowait --timeout"
|
||||
else
|
||||
if [[ "$prev" == "connect" ]]; then
|
||||
_nmcli_ap_ssid
|
||||
_nmcli_list_nl "$(_nmcli_ap_ssid)"
|
||||
else
|
||||
_nmcli_list "password wep-key-type iface bssid name"
|
||||
fi
|
||||
|
|
@ -222,7 +287,7 @@ _nmcli()
|
|||
if [[ "$cur" == i* ]]; then
|
||||
_nmcli_list "iface"
|
||||
else
|
||||
_nmcli_NM_devices
|
||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue