mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 06:38:11 +02:00
cli: make bash-completion for nmcli support more abbreviations.
Also sub commands can be abbreviated. Add some more aliases to the bash completion. Also fix the option 'nmcli radio mobile' which is called 'wwan'. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
faa6a12ba3
commit
e2f77d30b1
1 changed files with 133 additions and 120 deletions
|
|
@ -172,153 +172,166 @@ _nmcli()
|
||||||
|
|
||||||
case $object in
|
case $object in
|
||||||
g|ge|gen|gene|gener|genera|general)
|
g|ge|gen|gene|gener|genera|general)
|
||||||
case $command in
|
if [[ ${#words[@]} -gt 3 ]]; then
|
||||||
status | permissions)
|
case $command in
|
||||||
return 0
|
s|st|sta|stat|statu|status | p|pe|per|perm|permi|permis|permiss|permissi|permissio|permission|permissions)
|
||||||
;;
|
return 0
|
||||||
logging)
|
;;
|
||||||
_nmcli_list "level domains"
|
l|lo|log|logg|loggi|loggin|logging)
|
||||||
return 0
|
_nmcli_list "level domains"
|
||||||
;;
|
return 0
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
_nmcli_list "status permissions logging help"
|
_nmcli_list "status permissions logging help"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
n|ne|net|netw|netwo|networ|network|networki|networkin|networking)
|
n|ne|net|netw|netwo|networ|network|networki|networkin|networking)
|
||||||
case $command in
|
if [[ ${#words[@]} -gt 3 ]]; then
|
||||||
on | off)
|
case $command in
|
||||||
return 0
|
on | off)
|
||||||
;;
|
return 0
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
_nmcli_list "on off help"
|
_nmcli_list "on off help"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
r|ra|rad|radi|radio)
|
r|ra|rad|radi|radio)
|
||||||
case $command in
|
if [[ ${#words[@]} -gt 3 ]]; then
|
||||||
all | wifi | mobile | wimax)
|
case $command in
|
||||||
_nmcli_list "on off"
|
a|al|all | w|wi|wif|wifi | ww|wwa|wwan | wim|wima|wimax)
|
||||||
return 0
|
_nmcli_list "on off"
|
||||||
;;
|
return 0
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
_nmcli_list "all wifi mobile wimax help"
|
_nmcli_list "all wifi wwan wimax help"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
c|co|con|conn|conne|connec|connect|connecti|connectio|connection)
|
c|co|con|conn|conne|connec|connect|connecti|connectio|connection)
|
||||||
case $command in
|
if [[ ${#words[@]} -gt 3 ]]; then
|
||||||
show)
|
case $command in
|
||||||
local subcommand=${words[3]}
|
s|sh|sho|show)
|
||||||
|
local subcommand=${words[3]}
|
||||||
|
|
||||||
case $subcommand in
|
if [[ ${#words[@]} -gt 4 ]]; then
|
||||||
configured)
|
case $subcommand in
|
||||||
_nmcli_list "id uuid path"
|
c|co|con|conf|confi|config|configu|configur|configure|configured)
|
||||||
return 0
|
_nmcli_list "id uuid path"
|
||||||
;;
|
return 0
|
||||||
active)
|
;;
|
||||||
_nmcli_list "id uuid path apath"
|
a|ac|act|acti|activ|active)
|
||||||
return 0
|
_nmcli_list "id uuid path apath"
|
||||||
;;
|
return 0
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
_nmcli_list "configured active"
|
fi
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
up)
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
_nmcli_list "--nowait --timeout"
|
|
||||||
else
|
|
||||||
_nmcli_list "id uuid path iface ap nsp"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
down)
|
|
||||||
_nmcli_list "id uuid path apath"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
add)
|
|
||||||
_nmcli_list "type con-name autoconnect ifname help"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
edit)
|
|
||||||
_nmcli_list "id uuid path type con-name"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
modify)
|
|
||||||
_nmcli_list_nl "$(_nmcli_con_id)"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
delete)
|
|
||||||
_nmcli_list "id uuid path"
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
_nmcli_list "configured active"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
u|up)
|
||||||
|
if [[ "$cur" == -* ]]; then
|
||||||
|
_nmcli_list "--nowait --timeout"
|
||||||
|
else
|
||||||
|
_nmcli_list "id uuid path iface ap nsp"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
d|do|dow|down)
|
||||||
|
_nmcli_list "id uuid path apath"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
a|ad|add)
|
||||||
|
_nmcli_list "type con-name autoconnect ifname help"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
e|ed|edi|edit)
|
||||||
|
_nmcli_list "id uuid path type con-name"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
m|mo|mod|modi|modif|modify)
|
||||||
|
_nmcli_list_nl "$(_nmcli_con_id)"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
de|del|dele|delet|delete)
|
||||||
|
_nmcli_list "id uuid path"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
_nmcli_list "show up down add modify edit delete reload help"
|
_nmcli_list "show up down add modify edit delete reload help"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
d|de|dev|devi|devic|device)
|
d|de|dev|devi|devic|device)
|
||||||
case $command in
|
if [[ ${#words[@]} -gt 3 ]]; then
|
||||||
show)
|
case $command in
|
||||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
sh|sho|show)
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
disconnect)
|
|
||||||
if [[ "$cur" == -* ]]; then
|
|
||||||
_nmcli_list "--nowait --timeout"
|
|
||||||
else
|
|
||||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||||
fi
|
return 0
|
||||||
return 0
|
;;
|
||||||
;;
|
d|di|dis|disc|disco|discon|disconn|disconne|disconnec|disconnect)
|
||||||
wifi)
|
if [[ "$cur" == -* ]]; then
|
||||||
local subcommand=${words[3]}
|
_nmcli_list "--nowait --timeout"
|
||||||
|
else
|
||||||
|
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
w|wi|wif|wifi)
|
||||||
|
local subcommand=${words[3]}
|
||||||
|
|
||||||
case $subcommand in
|
case $subcommand in
|
||||||
list)
|
l|li|lis|list)
|
||||||
_nmcli_list "iface bssid"
|
_nmcli_list "iface bssid"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
connect)
|
c|co|con|conn|conne|connec|connect)
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
_nmcli_list "--private --nowait --timeout"
|
_nmcli_list "--private --nowait --timeout"
|
||||||
else
|
|
||||||
if [[ "$prev" == "connect" ]]; then
|
|
||||||
_nmcli_list_nl "$(_nmcli_ap_ssid)"
|
|
||||||
else
|
else
|
||||||
_nmcli_list "password wep-key-type iface bssid name"
|
if [[ "$prev" == "connect" ]]; then
|
||||||
|
_nmcli_list_nl "$(_nmcli_ap_ssid)"
|
||||||
|
else
|
||||||
|
_nmcli_list "password wep-key-type iface bssid name"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
return 0
|
||||||
return 0
|
;;
|
||||||
;;
|
r|re|res|resc|resca|rescan)
|
||||||
scan)
|
if [[ "$cur" == i* ]]; then
|
||||||
if [[ "$cur" == i* ]]; then
|
_nmcli_list "iface"
|
||||||
_nmcli_list "iface"
|
else
|
||||||
else
|
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
||||||
_nmcli_list_nl "$(_nmcli_NM_devices)"
|
fi
|
||||||
fi
|
return 0
|
||||||
return 0
|
;;
|
||||||
;;
|
esac
|
||||||
esac
|
|
||||||
|
|
||||||
_nmcli_list "list connect scan"
|
_nmcli_list "list connect scan"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
wimax)
|
wim|wima|wimax)
|
||||||
local subcommand=${words[3]}
|
local subcommand=${words[3]}
|
||||||
|
|
||||||
case $subcommand in
|
if [[ ${#words[@]} -gt 4 ]]; then
|
||||||
list)
|
case $subcommand in
|
||||||
_nmcli_list "iface nsp"
|
l|li|lis|list)
|
||||||
return 0
|
_nmcli_list "iface nsp"
|
||||||
;;
|
return 0
|
||||||
esac
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
_nmcli_list "list"
|
_nmcli_list "list"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
_nmcli_list "status show disconnect wifi wimax help"
|
_nmcli_list "status show disconnect wifi wimax help"
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue