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:
Thomas Haller
2013-08-09 16:43:36 +02:00
parent faa6a12ba3
commit e2f77d30b1

View File

@@ -172,59 +172,68 @@ _nmcli()
case $object in case $object in
g|ge|gen|gene|gener|genera|general) g|ge|gen|gene|gener|genera|general)
if [[ ${#words[@]} -gt 3 ]]; then
case $command in case $command in
status | permissions) s|st|sta|stat|statu|status | p|pe|per|perm|permi|permis|permiss|permissi|permissio|permission|permissions)
return 0 return 0
;; ;;
logging) l|lo|log|logg|loggi|loggin|logging)
_nmcli_list "level domains" _nmcli_list "level domains"
return 0 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)
if [[ ${#words[@]} -gt 3 ]]; then
case $command in case $command in
on | off) on | off)
return 0 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)
if [[ ${#words[@]} -gt 3 ]]; then
case $command in case $command in
all | wifi | mobile | wimax) a|al|all | w|wi|wif|wifi | ww|wwa|wwan | wim|wima|wimax)
_nmcli_list "on off" _nmcli_list "on off"
return 0 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)
if [[ ${#words[@]} -gt 3 ]]; then
case $command in case $command in
show) s|sh|sho|show)
local subcommand=${words[3]} local subcommand=${words[3]}
if [[ ${#words[@]} -gt 4 ]]; then
case $subcommand in case $subcommand in
configured) c|co|con|conf|confi|config|configu|configur|configure|configured)
_nmcli_list "id uuid path" _nmcli_list "id uuid path"
return 0 return 0
;; ;;
active) a|ac|act|acti|activ|active)
_nmcli_list "id uuid path apath" _nmcli_list "id uuid path apath"
return 0 return 0
;; ;;
esac esac
fi
_nmcli_list "configured active" _nmcli_list "configured active"
return 0 return 0
;; ;;
up) u|up)
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
_nmcli_list "--nowait --timeout" _nmcli_list "--nowait --timeout"
else else
@@ -232,38 +241,39 @@ _nmcli()
fi fi
return 0 return 0
;; ;;
down) d|do|dow|down)
_nmcli_list "id uuid path apath" _nmcli_list "id uuid path apath"
return 0 return 0
;; ;;
add) a|ad|add)
_nmcli_list "type con-name autoconnect ifname help" _nmcli_list "type con-name autoconnect ifname help"
return 0 return 0
;; ;;
edit) e|ed|edi|edit)
_nmcli_list "id uuid path type con-name" _nmcli_list "id uuid path type con-name"
return 0 return 0
;; ;;
modify) m|mo|mod|modi|modif|modify)
_nmcli_list_nl "$(_nmcli_con_id)" _nmcli_list_nl "$(_nmcli_con_id)"
return 0 return 0
;; ;;
delete) de|del|dele|delet|delete)
_nmcli_list "id uuid path" _nmcli_list "id uuid path"
return 0 return 0
;; ;;
esac 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)
if [[ ${#words[@]} -gt 3 ]]; then
case $command in case $command in
show) sh|sho|show)
_nmcli_list_nl "$(_nmcli_NM_devices)" _nmcli_list_nl "$(_nmcli_NM_devices)"
return 0 return 0
;; ;;
disconnect) d|di|dis|disc|disco|discon|disconn|disconne|disconnec|disconnect)
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
_nmcli_list "--nowait --timeout" _nmcli_list "--nowait --timeout"
else else
@@ -271,15 +281,15 @@ _nmcli()
fi fi
return 0 return 0
;; ;;
wifi) w|wi|wif|wifi)
local subcommand=${words[3]} 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 else
@@ -291,7 +301,7 @@ _nmcli()
fi fi
return 0 return 0
;; ;;
scan) r|re|res|resc|resca|rescan)
if [[ "$cur" == i* ]]; then if [[ "$cur" == i* ]]; then
_nmcli_list "iface" _nmcli_list "iface"
else else
@@ -304,21 +314,24 @@ _nmcli()
_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]}
if [[ ${#words[@]} -gt 4 ]]; then
case $subcommand in case $subcommand in
list) l|li|lis|list)
_nmcli_list "iface nsp" _nmcli_list "iface nsp"
return 0 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"
;; ;;