2013-04-03 17:00:48 +02:00
|
|
|
# nmcli(1) completion -*- shell-script -*-
|
|
|
|
|
# Originally based on
|
2013-02-17 02:07:36 +01:00
|
|
|
# https://github.com/GArik/bash-completion/blob/master/completions/nmcli
|
|
|
|
|
|
|
|
|
|
_nmcli_list()
|
|
|
|
|
{
|
|
|
|
|
COMPREPLY=( $( compgen -W '$1' -- $cur ) )
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 20:49:17 +02:00
|
|
|
_nmcli_list_nl()
|
2013-02-17 02:07:36 +01:00
|
|
|
{
|
|
|
|
|
local IFS=$'\n'
|
2013-04-12 20:49:17 +02:00
|
|
|
COMPREPLY=( $( compgen -W '$1' -- $cur ) )
|
2014-04-14 13:00:35 +02:00
|
|
|
|
|
|
|
|
# Now escape special characters (spaces, single and double quotes),
|
|
|
|
|
# so that the argument is really regarded a single argument by bash.
|
|
|
|
|
# See http://stackoverflow.com/questions/1146098/properly-handling-spaces-and-quotes-in-bash-completion
|
|
|
|
|
local escaped_single_quote="'\''"
|
|
|
|
|
local i=0
|
|
|
|
|
local entry
|
|
|
|
|
for entry in ${COMPREPLY[*]}
|
|
|
|
|
do
|
|
|
|
|
if [[ "${cur:0:1}" == "'" ]]; then
|
|
|
|
|
# started with single quote, escaping only other single quotes
|
|
|
|
|
# [']bla'bla"bla\bla bla --> [']bla'\''bla"bla\bla bla
|
|
|
|
|
COMPREPLY[$i]="${entry//\'/${escaped_single_quote}}"
|
|
|
|
|
elif [[ "${cur:0:1}" == '"' ]]; then
|
2016-10-17 15:07:50 +02:00
|
|
|
# started with double quote, escaping all double quotes, backslashes and !
|
2014-04-14 13:00:35 +02:00
|
|
|
# ["]bla'bla"bla\bla bla --> ["]bla'bla\"bla\\bla bla
|
|
|
|
|
entry="${entry//\\/\\\\}"
|
|
|
|
|
entry="${entry//\"/\\\"}"
|
2016-10-17 15:07:50 +02:00
|
|
|
entry="${entry//!/\"\\!\"}"
|
2014-04-14 13:00:35 +02:00
|
|
|
COMPREPLY[$i]="$entry"
|
|
|
|
|
else
|
|
|
|
|
# no quotes in front, escaping _everything_
|
|
|
|
|
# [ ]bla'bla"bla\bla bla --> [ ]bla\'bla\"bla\\bla\ bla
|
|
|
|
|
entry="${entry//\\/\\\\}"
|
|
|
|
|
entry="${entry//\'/\'}"
|
|
|
|
|
entry="${entry//\"/\\\"}"
|
|
|
|
|
entry="${entry// /\\ }"
|
2016-10-17 15:07:50 +02:00
|
|
|
entry="${entry//\(/\\(}"
|
|
|
|
|
entry="${entry//)/\\)}"
|
|
|
|
|
entry="${entry//!/\\!}"
|
|
|
|
|
entry="${entry//&/\\&}"
|
2014-04-14 13:00:35 +02:00
|
|
|
COMPREPLY[$i]="$entry"
|
|
|
|
|
fi
|
|
|
|
|
(( i++ ))
|
|
|
|
|
done
|
2015-10-14 14:10:07 +02:00
|
|
|
|
|
|
|
|
# Work-around bash_completion issue where bash interprets a colon
|
|
|
|
|
# as a separator.
|
|
|
|
|
# Colon is escaped here. Change "\\:" back to ":".
|
|
|
|
|
# See also:
|
|
|
|
|
# http://stackoverflow.com/questions/28479216/how-to-give-correct-suggestions-to-tab-complete-when-my-words-contains-colons
|
|
|
|
|
# http://stackoverflow.com/questions/2805412/bash-completion-for-maven-escapes-colon/12495727
|
|
|
|
|
i=0
|
|
|
|
|
for entry in ${COMPREPLY[*]}
|
|
|
|
|
do
|
|
|
|
|
entry="${entry//\\\\:/:}"
|
|
|
|
|
COMPREPLY[$i]=${entry}
|
|
|
|
|
(( i++ ))
|
|
|
|
|
done
|
2013-04-12 20:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_con_show()
|
2013-04-12 20:49:17 +02:00
|
|
|
{
|
2014-01-17 20:02:51 +01:00
|
|
|
nmcli -t -f "$1" connection show $2 2> /dev/null
|
2013-02-17 02:07:36 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_wifi_list()
|
2013-08-21 19:45:45 +02:00
|
|
|
{
|
2014-01-10 00:49:36 +01:00
|
|
|
nmcli -t -f "$1" device wifi list 2>/dev/null
|
2013-08-21 19:45:45 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_dev_status()
|
2013-02-17 02:07:36 +01:00
|
|
|
{
|
2014-01-10 00:49:36 +01:00
|
|
|
nmcli -t -f "$1" device status 2>/dev/null
|
2013-04-03 17:00:48 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
_nmcli_array_has_value() {
|
2014-03-01 00:35:15 +01:00
|
|
|
# expects the name of an array as first parameter and
|
|
|
|
|
# returns true if if one of the remaining arguments is
|
|
|
|
|
# contained in the array ${$1[@]}
|
|
|
|
|
eval "local ARRAY=(\"\${$1[@]}\")"
|
2013-08-28 19:58:11 +02:00
|
|
|
local arg a
|
2014-03-01 00:35:15 +01:00
|
|
|
shift
|
2013-08-28 19:58:11 +02:00
|
|
|
for arg; do
|
|
|
|
|
for a in "${ARRAY[@]}"; do
|
|
|
|
|
if [[ "$a" = "$arg" ]]; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at()
|
|
|
|
|
{
|
|
|
|
|
eval "local ARRAY=(\"\${$1[@]}\")"
|
|
|
|
|
local i
|
|
|
|
|
local tmp=()
|
|
|
|
|
local lower=$2
|
|
|
|
|
local upper=${3:-$lower}
|
|
|
|
|
|
|
|
|
|
# for some reason the following fails. So this clumsy workaround...
|
|
|
|
|
# A=(a "")
|
|
|
|
|
# echo " >> ${#A[@]}"
|
|
|
|
|
# >> 2
|
|
|
|
|
# A=("${A[@]:1}")
|
|
|
|
|
# echo " >> ${#A[@]}"
|
|
|
|
|
# >> 0
|
|
|
|
|
# ... seriously???
|
|
|
|
|
|
|
|
|
|
for i in "${!ARRAY[@]}"; do
|
|
|
|
|
if [[ "$i" -lt "$2" || "$i" -gt "${3-$2}" ]]; then
|
|
|
|
|
tmp=("${tmp[@]}" "${ARRAY[$i]}")
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
eval "$1=(\"\${tmp[@]}\")"
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-28 13:08:28 +01:00
|
|
|
_nmcli_compl_match_option()
|
|
|
|
|
{
|
|
|
|
|
local S="$1"
|
|
|
|
|
local V
|
|
|
|
|
shift
|
|
|
|
|
if [[ "${S:0:2}" == "--" ]]; then
|
|
|
|
|
S="${S:2}"
|
|
|
|
|
elif [[ "${S:0:1}" == "-" ]]; then
|
|
|
|
|
S="${S:1}"
|
2016-06-28 12:12:39 +02:00
|
|
|
else
|
|
|
|
|
return 1
|
2014-02-28 13:08:28 +01:00
|
|
|
fi
|
|
|
|
|
for V; do
|
|
|
|
|
case "$V" in
|
|
|
|
|
"$S"*)
|
2014-03-01 01:35:23 +01:00
|
|
|
printf "%s" "$V"
|
2014-02-28 13:08:28 +01:00
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 18:55:11 +02:00
|
|
|
# OPTIONS appear first at the command line (before the OBJECT).
|
|
|
|
|
# This iterates over the argument list and tries to complete
|
|
|
|
|
# the options. If there are options that are to be completed,
|
|
|
|
|
# zero is returned and completion will be performed.
|
|
|
|
|
# Otherwise it will remove all the option parameters from the ${words[@]}
|
|
|
|
|
# array and return with zero (so that completion of OBJECT can continue).
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_OPTIONS()
|
2013-08-21 18:55:11 +02:00
|
|
|
{
|
2014-03-01 01:51:34 +01:00
|
|
|
local i W
|
2013-08-21 18:55:11 +02:00
|
|
|
|
|
|
|
|
for (( ; ; )); do
|
|
|
|
|
if [[ "${#words[@]}" -le 1 ]]; then
|
2014-02-28 13:08:28 +01:00
|
|
|
return 1
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
2014-02-28 13:08:28 +01:00
|
|
|
W="$(_nmcli_compl_match_option "${words[0]}" "${LONG_OPTIONS[@]}")"
|
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
|
return 2
|
|
|
|
|
fi
|
2014-03-01 01:51:34 +01:00
|
|
|
|
|
|
|
|
# remove the options already seen.
|
|
|
|
|
for i in ${!LONG_OPTIONS[@]}; do
|
|
|
|
|
if [[ "${LONG_OPTIONS[$i]}" == "$W" ]]; then
|
|
|
|
|
_nmcli_array_delete_at LONG_OPTIONS $i
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == '1' ]]; then
|
|
|
|
|
for i in ${!LONG_OPTIONS[@]}; do
|
|
|
|
|
if [[ "${LONG_OPTIONS[$i]}" == "help" ]]; then
|
|
|
|
|
_nmcli_array_delete_at LONG_OPTIONS $i
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2014-02-28 13:08:28 +01:00
|
|
|
case "$W" in
|
|
|
|
|
terse)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
pretty)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
ask)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2015-12-04 13:29:42 +01:00
|
|
|
show-secrets)
|
|
|
|
|
_nmcli_array_delete_at words 0
|
|
|
|
|
;;
|
2015-02-23 18:29:18 +01:00
|
|
|
order)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
local ord="${words[1]}"
|
|
|
|
|
local ord_sta=""
|
|
|
|
|
local i
|
|
|
|
|
local c=()
|
|
|
|
|
|
|
|
|
|
# FIXME: currently the completion considers colon as separator
|
|
|
|
|
# for words. Hence the following doesn't work as $ord will
|
|
|
|
|
# not contain any colons at this point.
|
|
|
|
|
# See https://bugzilla.gnome.org/show_bug.cgi?id=745157
|
|
|
|
|
|
|
|
|
|
if [[ $ord = *":"* ]]; then
|
|
|
|
|
ord_sta="${ord%:*}:"
|
|
|
|
|
ord="${ord##*:}"
|
|
|
|
|
fi
|
|
|
|
|
if [[ $ord = [-+]* ]]; then
|
|
|
|
|
ord_sta="$ord_sta${ord:0:1}"
|
|
|
|
|
fi
|
|
|
|
|
for i in active name type path; do
|
|
|
|
|
c=("${c[@]}" "$ord_sta$i")
|
|
|
|
|
done
|
|
|
|
|
_nmcli_list "${c[*]}"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
;;
|
2014-03-02 15:49:22 +01:00
|
|
|
active)
|
|
|
|
|
_nmcli_array_delete_at words 0
|
|
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
version)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
help)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2014-03-01 01:51:34 +01:00
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
HELP_ONLY_AS_FIRST=0
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
HELP_ONLY_AS_FIRST=0
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-02-28 13:37:25 +01:00
|
|
|
temporary)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2014-02-28 13:37:25 +01:00
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
mode)
|
2013-08-21 18:55:11 +02:00
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "tabular multiline"
|
2016-06-10 14:48:43 +02:00
|
|
|
return 0
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2015-02-23 17:51:04 +01:00
|
|
|
colors)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "yes no auto"
|
2016-06-10 14:48:43 +02:00
|
|
|
return 0
|
2015-02-23 17:51:04 +01:00
|
|
|
fi
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
fields)
|
2013-08-21 18:55:11 +02:00
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_list "all common
|
|
|
|
|
NAME UUID TYPE TIMESTAMP TIMESTAMP-REAL AUTOCONNECT READONLY DBUS-PATH ACTIVE DEVICE STATE ACTIVE-PATH
|
2015-12-17 16:42:54 +01:00
|
|
|
connection 802-3-ethernet 802-1x 802-11-wireless 802-11-wireless-security ipv4 ipv6 serial ppp pppoe gsm cdma bluetooth 802-11-olpc-mesh vpn wimax infiniband bond vlan adsl bridge bridge-port team team-port dcb tun ip-tunnel macvlan vxlan
|
2014-01-17 20:02:51 +01:00
|
|
|
GENERAL IP4 DHCP4 IP6 DHCP6 VPN
|
|
|
|
|
profile active"
|
2016-06-10 14:48:43 +02:00
|
|
|
return 0
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
escape)
|
2013-08-21 18:55:11 +02:00
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "no yes"
|
2016-06-10 14:48:43 +02:00
|
|
|
return 0
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-02-28 13:08:28 +01:00
|
|
|
wait)
|
2013-08-21 18:55:11 +02:00
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list ""
|
2016-06-10 14:48:43 +02:00
|
|
|
return 0
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
# something unexpected. We are finished with parsing the OPTIONS.
|
2014-02-28 13:08:28 +01:00
|
|
|
return 2
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
# after the OPTIONS, the OBJECT, the COMMAND and possible the COMMAND_CONNECTION, the syntax for nmcli
|
|
|
|
|
# expects several options with parameters. This function can parse them and remove them from the words array.
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS()
|
2013-02-17 02:07:36 +01:00
|
|
|
{
|
2015-11-23 17:21:02 +01:00
|
|
|
local aliases=${@}
|
2013-08-28 19:58:11 +02:00
|
|
|
local OPTIONS_ALL N_REMOVE_WORDS REMOVE_OPTIONS OPTIONS_HAS_MANDATORY i
|
|
|
|
|
OPTIONS_ALL=("${OPTIONS[@]}")
|
|
|
|
|
OPTIONS_UNKNOWN_OPTION=
|
2013-02-17 02:07:36 +01:00
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
OPTIONS_HAS_MANDATORY=0
|
|
|
|
|
if [[ "${#OPTIONS_MANDATORY[@]}" -ge 1 ]]; then
|
|
|
|
|
OPTIONS_HAS_MANDATORY=1
|
|
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
for (( ; ; )); do
|
|
|
|
|
if [[ "${#words[@]}" -le 1 ]]; then
|
|
|
|
|
# we have no more words left...
|
|
|
|
|
if [[ ${#OPTIONS[@]} -eq 0 ]]; then
|
|
|
|
|
return 1;
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$COMMAND_ARGS_WAIT_OPTIONS" -ne 1 ]]; then
|
|
|
|
|
_nmcli_list "$(echo "${OPTIONS[@]}")"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
COMMAND_ARGS_WAIT_OPTIONS=0
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
if ! _nmcli_array_has_value OPTIONS_ALL "${words[0]}"; then
|
2013-08-28 19:58:11 +02:00
|
|
|
# This is an entirely unknown option.
|
|
|
|
|
OPTIONS_UNKNOWN_OPTION="?${words[0]}"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$OPTIONS_HAS_MANDATORY" -eq 1 && "${#OPTIONS_MANDATORY[@]}" -eq 0 ]]; then
|
|
|
|
|
# we had some mandatory options, but they are all satisfied... stop here...
|
|
|
|
|
# This means, that we can continue with more additional options from the NEXT_GROUP.
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
N_REMOVE_WORDS=2
|
|
|
|
|
REMOVE_OPTIONS=("${words[0]}")
|
2015-11-23 17:21:02 +01:00
|
|
|
|
|
|
|
|
# change option name to alias
|
|
|
|
|
WORD0="${words[0]}"
|
|
|
|
|
for alias in "${aliases[@]}" ; do
|
|
|
|
|
if [[ "${WORD0}" == ${alias%%:*} ]]; then
|
|
|
|
|
WORD0=${alias#*:}
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
case "${WORD0}" in
|
2013-08-28 19:58:11 +02:00
|
|
|
level)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2016-06-27 11:33:33 +02:00
|
|
|
_nmcli_list "OFF ERR WARN INFO DEBUG TRACE KEEP"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
domains)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2016-06-27 11:33:33 +02:00
|
|
|
local OPTIONS_DOM=(ALL DEFAULT DHCP IP PLATFORM RFKILL ETHER WIFI BT MB DHCP4 DHCP6 PPP WIFI_SCAN IP4 IP6 AUTOIP4 DNS VPN SHARING SUPPLICANT AGENTS SETTINGS SUSPEND CORE DEVICE OLPC WIMAX INFINIBAND FIREWALL ADSL BOND VLAN BRIDGE DBUS_PROPS TEAM CONCHECK DCB DISPATCH AUDIT SYSTEMD VPN_PLUGIN)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ "${words[1]}" != "" ]]; then
|
|
|
|
|
|
|
|
|
|
# split the comma separaeted domain string into its parts LOGD
|
|
|
|
|
local oIFS="$IFS"
|
|
|
|
|
IFS=","
|
2014-03-01 01:35:23 +01:00
|
|
|
local LOGD=($(printf '%s' "${words[1]}" | sed 's/\(^\|,\)/,#/g'))
|
2013-08-28 19:58:11 +02:00
|
|
|
IFS="$oIFS"
|
|
|
|
|
unset oIFS
|
|
|
|
|
|
|
|
|
|
local LOGDLAST LOGDLAST_IS_OPTION LOGDI i
|
|
|
|
|
# first we iterate over all present domains and remove them from OPTIONS_DOM
|
|
|
|
|
for LOGDI in ${LOGD[@]}; do
|
|
|
|
|
LOGDI="${LOGDI:1}"
|
|
|
|
|
LOGDLAST="$LOGDI"
|
|
|
|
|
LOGDLAST_IS_OPTION=0
|
|
|
|
|
for i in ${!OPTIONS_DOM[*]}; do
|
|
|
|
|
if [[ "${OPTIONS_DOM[$i]}" = "$LOGDI" ]]; then
|
|
|
|
|
LOGDLAST_IS_OPTION=1
|
|
|
|
|
unset OPTIONS_DOM[$i]
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
local OPTIONS_DOM2=()
|
|
|
|
|
if [[ "$LOGDLAST" = "" ]]; then
|
|
|
|
|
# we have a word that ends with ','. Just append all remaining options.
|
|
|
|
|
for i in ${!OPTIONS_DOM[*]}; do
|
|
|
|
|
OPTIONS_DOM2[${#OPTIONS_DOM2[@]}]="${words[1]}${OPTIONS_DOM[$i]}"
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
# if the last option is not "" we keep only those option with the same prefix
|
|
|
|
|
# as the last domain (LOGDLAST)
|
|
|
|
|
for i in ${!OPTIONS_DOM[*]}; do
|
|
|
|
|
if [[ "${OPTIONS_DOM[$i]:0:${#LOGDLAST}}" == "$LOGDLAST" ]]; then
|
|
|
|
|
# modify the option with the present prefix
|
|
|
|
|
OPTIONS_DOM2[${#OPTIONS_DOM2[@]}]="${words[1]}${OPTIONS_DOM[$i]:${#LOGDLAST}}"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [[ $LOGDLAST_IS_OPTION -eq 1 ]]; then
|
|
|
|
|
# if the last logd itself was a valid iption, ${words[1]} is itself a valid match
|
|
|
|
|
OPTIONS_DOM2[${#OPTIONS_DOM2[@]}]="${words[1]}"
|
|
|
|
|
|
|
|
|
|
# also, add all remaining options by comma separated to the word.
|
|
|
|
|
for i in ${!OPTIONS_DOM[*]}; do
|
|
|
|
|
OPTIONS_DOM2[${#OPTIONS_DOM2[@]}]="${words[1]},${OPTIONS_DOM[$i]}"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
if [[ ${#OPTIONS_DOM2[@]} -eq 1 ]]; then
|
|
|
|
|
for i in ${!OPTIONS_DOM[*]}; do
|
|
|
|
|
if [[ "$LOGDLAST" != "${OPTIONS_DOM[$i]:0:${#LOGDLAST}}" ]]; then
|
|
|
|
|
OPTIONS_DOM2[${#OPTIONS_DOM2[@]}]="${OPTIONS_DOM2[0]},${OPTIONS_DOM[$i]}"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
OPTIONS_DOM=(${OPTIONS_DOM2[@]})
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_nmcli_list "$(echo "${OPTIONS_DOM[@]}")"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
type)
|
|
|
|
|
if [[ "$OPTIONS_TYPE" != "" ]]; then
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2013-09-06 17:43:38 +02:00
|
|
|
if [[ "${words[1]:0:1}" = "8" ]]; then
|
|
|
|
|
# usually we don't want to show the 802-x types (because the shorter aliases are more
|
|
|
|
|
# user friendly. Only complete them, if the current word already starts with an "8".
|
|
|
|
|
_nmcli_list "802-3-ethernet 802-11-wireless 802-11-olpc-mesh"
|
|
|
|
|
else
|
2015-10-13 18:53:10 +02:00
|
|
|
_nmcli_list "ethernet wifi wimax gsm cdma infiniband bluetooth vpn olpc-mesh vlan bond bridge team pppoe adsl tun ip-tunnel macvlan vxlan"
|
2013-09-06 17:43:38 +02:00
|
|
|
fi
|
2014-01-30 15:42:46 +01:00
|
|
|
return 0
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
|
|
|
|
OPTIONS_TYPE="${words[1]}"
|
2014-01-30 15:42:46 +01:00
|
|
|
|
|
|
|
|
if [[ "x$OPTIONS_MANDATORY_IFNAME" != x ]]; then
|
|
|
|
|
# the ifname is not a mandatory option for a few connection types...
|
|
|
|
|
# Check, if we have such a 'type' and remove the 'ifname' from the list
|
|
|
|
|
# of mandatory options.
|
|
|
|
|
case "$OPTIONS_TYPE" in
|
|
|
|
|
vl|vla|vlan| \
|
|
|
|
|
bond| \
|
|
|
|
|
team| \
|
|
|
|
|
bridge)
|
|
|
|
|
for i in ${!OPTIONS_MANDATORY[*]}; do
|
|
|
|
|
if [[ "${OPTIONS_MANDATORY[$i]}" = "ifname" ]]; then
|
|
|
|
|
unset OPTIONS_MANDATORY[$i]
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
OPTIONS_MANDATORY_IFNAME=
|
|
|
|
|
fi
|
2013-08-28 19:58:11 +02:00
|
|
|
;;
|
|
|
|
|
master)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
if [[ "${words[1]}" = "" ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_dev_status DEVICE)"
|
2013-08-28 19:58:11 +02:00
|
|
|
else
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_list_nl "$(printf "%s\n%s\n%s" "$(_nmcli_dev_status DEVICE)" "$(_nmcli_con_show UUID)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
dev)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
if [[ "${words[1]}" = "" ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_dev_status DEVICE)"
|
2013-08-28 19:58:11 +02:00
|
|
|
else
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_list_nl "$(printf "%s\n%s\n%s" "$(_nmcli_dev_status DEVICE)" "$(_nmcli_wifi_list BSSID)" "$(_nmcli_con_show UUID)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-10-02 14:19:12 +02:00
|
|
|
primary| \
|
2013-08-28 19:58:11 +02:00
|
|
|
ifname)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_dev_status DEVICE)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
mode)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2014-10-04 17:07:42 +02:00
|
|
|
case "$OPTIONS_TYPE" in
|
|
|
|
|
"wifi")
|
|
|
|
|
_nmcli_list "infrastructure ap adhoc"
|
|
|
|
|
;;
|
2015-12-17 16:28:42 +01:00
|
|
|
"tun")
|
|
|
|
|
_nmcli_list "tun tap"
|
|
|
|
|
;;
|
|
|
|
|
"ip-tunnel")
|
|
|
|
|
_nmcli_list "ipip gre sit isatap vti ip6ip6 ipip6 ip6gre vti6"
|
|
|
|
|
;;
|
|
|
|
|
"macvlan")
|
|
|
|
|
_nmcli_list "vepa bridge private passthru source"
|
|
|
|
|
;;
|
2014-10-04 17:07:42 +02:00
|
|
|
"bond"| \
|
|
|
|
|
*)
|
|
|
|
|
_nmcli_list "balance-rr active-backup balance-xor broadcast 802.3ad balance-tlb balance-alb"
|
|
|
|
|
esac
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
transport-mode)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "datagram connected"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
vpn-type)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2016-05-19 09:40:44 +02:00
|
|
|
_nmcli_list "vpnc openvpn pptp openconnect openswan libreswan strongswan ssh l2tp iodine fortisslvpn"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-07-15 15:56:52 +02:00
|
|
|
slave-type)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "bond team bridge"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2014-08-25 12:59:49 +02:00
|
|
|
lacp-rate)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "slow fast"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-28 19:58:11 +02:00
|
|
|
bt-type)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "panu dun-gsm dun-cdma"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
wep-key-type)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "key phrase"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-03-23 14:11:43 +01:00
|
|
|
managed| \
|
2013-08-28 19:58:11 +02:00
|
|
|
autoconnect| \
|
|
|
|
|
stp| \
|
|
|
|
|
hairpin| \
|
2014-01-28 16:42:14 +01:00
|
|
|
save| \
|
2015-07-10 13:16:21 +02:00
|
|
|
hidden| \
|
2015-12-17 16:28:42 +01:00
|
|
|
private| \
|
|
|
|
|
pi| \
|
|
|
|
|
vnet-hdr| \
|
|
|
|
|
multi-queue|\
|
|
|
|
|
tap)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "yes no"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-11-18 12:06:05 +01:00
|
|
|
config)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
compopt -o default
|
|
|
|
|
COMPREPLY=()
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-28 19:58:11 +02:00
|
|
|
ip4| \
|
|
|
|
|
ip6| \
|
|
|
|
|
gw4| \
|
|
|
|
|
gw6| \
|
|
|
|
|
priority| \
|
|
|
|
|
forward-delay| \
|
|
|
|
|
hello-time| \
|
|
|
|
|
max-age| \
|
|
|
|
|
ageing-time| \
|
|
|
|
|
nsp| \
|
|
|
|
|
path-cost| \
|
|
|
|
|
name| \
|
|
|
|
|
mtu| \
|
|
|
|
|
cloned-mac| \
|
|
|
|
|
addr| \
|
|
|
|
|
parent| \
|
|
|
|
|
miimon| \
|
|
|
|
|
arp-interval| \
|
|
|
|
|
arp-ip-target| \
|
|
|
|
|
downdelay| \
|
|
|
|
|
updelay| \
|
|
|
|
|
p-key| \
|
|
|
|
|
mac| \
|
|
|
|
|
id| \
|
|
|
|
|
flags| \
|
|
|
|
|
ingress| \
|
|
|
|
|
dhcp-anycast| \
|
|
|
|
|
channel| \
|
|
|
|
|
egress| \
|
|
|
|
|
apn| \
|
|
|
|
|
con-name| \
|
|
|
|
|
user| \
|
2013-12-13 12:34:54 +01:00
|
|
|
username| \
|
|
|
|
|
service| \
|
2016-05-19 09:40:44 +02:00
|
|
|
password)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-11-23 17:21:02 +01:00
|
|
|
passwd-file| \
|
|
|
|
|
file)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2016-05-19 09:40:44 +02:00
|
|
|
compopt -o default
|
|
|
|
|
COMPREPLY=()
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
ssid)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_wifi_list SSID)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
ap| \
|
|
|
|
|
bssid)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_wifi_list BSSID)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-09-18 12:05:49 +02:00
|
|
|
encapsulation)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "vcmux llc"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
protocol)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "pppoa pppoe ipoatm"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-10-02 22:46:53 +02:00
|
|
|
band)
|
|
|
|
|
if [[ "${#words[@]}" -eq 2 ]]; then
|
|
|
|
|
_nmcli_list "a bg"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-28 19:58:11 +02:00
|
|
|
*)
|
|
|
|
|
return 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "${#OPTIONS_NEXT_GROUP[@]}" -gt 0 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
if _nmcli_array_has_value OPTIONS_NEXT_GROUP "${words[0]}"; then
|
2013-08-28 19:58:11 +02:00
|
|
|
# the current value is from the next group...
|
|
|
|
|
# We back off, because the current group is complete.
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 $((N_REMOVE_WORDS-1))
|
2013-08-28 19:58:11 +02:00
|
|
|
# remove the options already seen.
|
|
|
|
|
for i in ${!OPTIONS[*]}; do
|
|
|
|
|
if [[ "${OPTIONS[$i]}" = "${REMOVE_OPTIONS[0]}" || "${OPTIONS[$i]}" = "${REMOVE_OPTIONS[1]}" ]]; then
|
2015-07-14 09:50:56 +02:00
|
|
|
if ! _nmcli_array_has_value OPTIONS_REPEATABLE "${OPTIONS[$i]}" ; then
|
|
|
|
|
unset OPTIONS[$i]
|
|
|
|
|
fi
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
for i in ${!OPTIONS_MANDATORY[*]}; do
|
|
|
|
|
if [[ "${OPTIONS_MANDATORY[$i]}" = "${REMOVE_OPTIONS[0]}" || "${OPTIONS_MANDATORY[$i]}" = "${REMOVE_OPTIONS[1]}" ]]; then
|
|
|
|
|
unset OPTIONS_MANDATORY[$i]
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
}
|
2013-08-21 18:55:11 +02:00
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
# some commands expect a connection as parameter. This connection can either be given
|
|
|
|
|
# as id|uuid|path|apath. Parse that connection parameter.
|
2015-09-18 10:49:19 +02:00
|
|
|
# Actually, it can also ask for a device name, like `nmcli device set [ifname] <ifname>`
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS_CONNECTION()
|
2013-08-28 19:58:11 +02:00
|
|
|
{
|
2014-03-01 00:35:15 +01:00
|
|
|
if ! _nmcli_array_has_value OPTIONS "${words[0]}"; then
|
2013-10-24 14:42:20 +02:00
|
|
|
COMMAND_CONNECTION_TYPE=
|
|
|
|
|
COMMAND_CONNECTION_ID="${words[0]}"
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2013-08-28 19:58:11 +02:00
|
|
|
return 1
|
|
|
|
|
fi
|
2013-10-24 14:42:20 +02:00
|
|
|
COMMAND_CONNECTION_TYPE="${words[0]}"
|
|
|
|
|
COMMAND_CONNECTION_ID="${words[1]}"
|
2014-01-17 20:02:51 +01:00
|
|
|
local CON_TYPE=
|
2014-01-10 01:01:31 +01:00
|
|
|
if [[ "x$COMMAND_CONNECTION_ACTIVE" != x ]]; then
|
2014-01-17 20:02:51 +01:00
|
|
|
CON_TYPE=--active
|
2014-01-10 01:01:31 +01:00
|
|
|
fi
|
2013-08-28 19:58:11 +02:00
|
|
|
case "${words[0]}" in
|
2013-02-17 02:07:36 +01:00
|
|
|
id)
|
2014-01-17 20:02:51 +01:00
|
|
|
if [[ ${#words[@]} -le 2 ]]; then
|
2014-01-10 01:01:31 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_con_show NAME $CON_TYPE)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-02-17 02:07:36 +01:00
|
|
|
;;
|
|
|
|
|
uuid)
|
2014-01-17 20:02:51 +01:00
|
|
|
if [[ ${#words[@]} -le 2 ]]; then
|
2014-01-10 01:01:31 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_con_show UUID $CON_TYPE)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-02-17 02:07:36 +01:00
|
|
|
;;
|
2013-04-03 17:00:48 +02:00
|
|
|
path)
|
2014-01-17 20:02:51 +01:00
|
|
|
if [[ ${#words[@]} -le 2 ]]; then
|
|
|
|
|
_nmcli_list_nl "$(_nmcli_con_show DBUS-PATH $CON_TYPE)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-04-03 17:00:48 +02:00
|
|
|
;;
|
|
|
|
|
apath)
|
2014-01-17 20:02:51 +01:00
|
|
|
if [[ ${#words[@]} -le 2 ]]; then
|
|
|
|
|
_nmcli_list_nl "$(_nmcli_con_show ACTIVE-PATH --active)"
|
2013-08-28 19:58:11 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-04-12 20:49:17 +02:00
|
|
|
;;
|
2013-09-06 10:05:47 -05:00
|
|
|
ifname)
|
2014-01-17 20:02:51 +01:00
|
|
|
if [[ ${#words[@]} -le 2 ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_dev_status DEVICE)"
|
2013-09-06 10:05:47 -05:00
|
|
|
return 0
|
|
|
|
|
fi
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2013-09-06 10:05:47 -05:00
|
|
|
;;
|
2013-08-28 19:58:11 +02:00
|
|
|
*)
|
2013-10-24 14:42:20 +02:00
|
|
|
COMMAND_CONNECTION_TYPE=
|
|
|
|
|
COMMAND_CONNECTION_ID="${words[0]}"
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0
|
2013-04-12 20:49:17 +02:00
|
|
|
;;
|
2013-02-17 02:07:36 +01:00
|
|
|
esac
|
2013-08-28 19:58:11 +02:00
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND() {
|
2013-11-11 14:46:47 +01:00
|
|
|
local command="$1"
|
|
|
|
|
shift
|
2014-03-02 15:49:22 +01:00
|
|
|
local V=("$@")
|
|
|
|
|
local H=
|
|
|
|
|
if [[ "${command[0]:0:1}" != '-' ]]; then
|
|
|
|
|
H=help
|
|
|
|
|
elif [[ "${command[0]:1:1}" == '-' || "${command[0]}" == "-" ]]; then
|
|
|
|
|
H=--help
|
2013-11-11 14:46:47 +01:00
|
|
|
else
|
2014-03-02 15:49:22 +01:00
|
|
|
H=-help
|
|
|
|
|
fi
|
|
|
|
|
if [[ "x$COMPL_COMMAND_NO_HELP" == x ]]; then
|
|
|
|
|
V=("${V[@]}" "$H")
|
2013-11-11 14:46:47 +01:00
|
|
|
fi
|
2014-03-02 15:49:22 +01:00
|
|
|
_nmcli_list "${V[*]}"
|
2013-11-11 14:46:47 +01:00
|
|
|
}
|
2013-08-28 19:58:11 +02:00
|
|
|
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND_nl() {
|
2014-01-10 00:52:58 +01:00
|
|
|
local command="$1"
|
2014-02-28 13:36:14 +01:00
|
|
|
local a="$2"
|
2014-01-10 00:52:58 +01:00
|
|
|
shift
|
2014-02-28 13:36:14 +01:00
|
|
|
shift
|
|
|
|
|
local V=("$@")
|
2014-03-01 01:51:34 +01:00
|
|
|
local H=
|
2014-02-28 13:36:14 +01:00
|
|
|
if [[ "${command[0]:0:1}" != '-' ]]; then
|
2014-03-01 01:51:34 +01:00
|
|
|
V=("${V[@]/#/--}")
|
|
|
|
|
H=help
|
2014-02-28 13:36:14 +01:00
|
|
|
elif [[ "${command[0]:1:1}" == '-' || "${command[0]}" == "-" ]]; then
|
2014-03-01 01:51:34 +01:00
|
|
|
V=("${V[@]/#/--}")
|
|
|
|
|
H=--help
|
2014-01-10 00:52:58 +01:00
|
|
|
else
|
2014-03-01 01:51:34 +01:00
|
|
|
V=("${V[@]/#/-}")
|
|
|
|
|
H=-help
|
|
|
|
|
fi
|
|
|
|
|
if [[ "x$COMPL_COMMAND_NO_HELP" == x ]]; then
|
|
|
|
|
V=("${V[@]}" "$H")
|
2014-01-10 00:52:58 +01:00
|
|
|
fi
|
2014-02-28 13:36:14 +01:00
|
|
|
local IFS=$'\n'
|
|
|
|
|
V="${V[*]}"
|
|
|
|
|
_nmcli_list_nl "$(printf "%s%s\n%s" "" "$V" "$a")"
|
2014-01-10 00:52:58 +01:00
|
|
|
}
|
|
|
|
|
|
2015-07-01 11:38:52 +02:00
|
|
|
_nmcli_compl_PROPERTIES()
|
|
|
|
|
{
|
2016-06-15 13:12:39 +02:00
|
|
|
while [[ ${#words[@]} -gt 0 ]]; do
|
|
|
|
|
if [[ ${#words[@]} -eq 1 ]]; then
|
|
|
|
|
_nmcli_list_nl "$(nmcli --complete-args connection modify "$@" "${words[@]}" 2>/dev/null)"
|
2015-07-01 11:38:52 +02:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
done
|
2016-06-15 13:12:39 +02:00
|
|
|
return 0
|
2015-07-01 11:38:52 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
_nmcli()
|
|
|
|
|
{
|
2014-03-01 01:51:34 +01:00
|
|
|
local cur prev words cword i
|
2013-08-28 19:58:11 +02:00
|
|
|
_init_completion || return
|
2013-02-17 02:07:36 +01:00
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
# we don't care about any arguments after the current cursor position
|
|
|
|
|
# because we only parse from left to right. So, if there are some arguments
|
|
|
|
|
# right of the cursor, just ignore them. Also don't care about ${words[0]}.
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words $((cword+1)) ${#words[@]}
|
|
|
|
|
_nmcli_array_delete_at words 0
|
2013-08-28 19:58:11 +02:00
|
|
|
|
2013-11-12 18:19:05 +01:00
|
|
|
# _init_completion returns the words with all the quotes and escaping
|
|
|
|
|
# characters. We don't care about them, drop them at first.
|
2014-03-01 01:35:23 +01:00
|
|
|
for i in ${!words[@]}; do
|
|
|
|
|
words[i]="$(printf '%s' "${words[i]}" | xargs printf '%s\n' 2>/dev/null || true)"
|
2013-11-12 18:19:05 +01:00
|
|
|
done
|
|
|
|
|
|
2013-11-13 14:38:13 +01:00
|
|
|
# In case the cursor is not at the end of the line,
|
|
|
|
|
# $cur consists of spaces that we want do remove.
|
|
|
|
|
# For example: `nmcli connection modify id <TAB> lo`
|
2013-11-13 14:38:13 +01:00
|
|
|
if [[ "$cur" =~ ^[[:space:]]+ ]]; then
|
2013-11-13 14:38:13 +01:00
|
|
|
cur=''
|
|
|
|
|
fi
|
|
|
|
|
|
2016-06-10 14:48:43 +02:00
|
|
|
local OPTIONS OPTIONS_UNKNOWN_OPTION OPTIONS_TYPE OPTIONS_TYPED OPTIONS_IP OPTIONS_NEXT_GROUP \
|
|
|
|
|
OPTIONS_SEP OPTIONS_REPEATABLE OPTIONS_MANDATORY OPTIONS_MANDATORY_IFNAME \
|
|
|
|
|
COMMAND_ARGS_WAIT_OPTIONS COMMAND_CONNECTION_TYPE COMMAND_CONNECTION_ID \
|
|
|
|
|
COMMAND_CONNECTION_ACTIVE="" HELP_ONLY_AS_FIRST="" \
|
|
|
|
|
LONG_OPTIONS=(terse pretty mode fields colors escape ask show-secrets wait version help)
|
2013-08-28 19:58:11 +02:00
|
|
|
|
2014-02-28 13:08:28 +01:00
|
|
|
_nmcli_compl_OPTIONS
|
2014-03-01 01:51:34 +01:00
|
|
|
i=$?
|
|
|
|
|
|
|
|
|
|
case $i in
|
2014-02-28 13:08:28 +01:00
|
|
|
0)
|
2016-06-10 14:48:43 +02:00
|
|
|
# We have just completed an option or got an --help: terminate.
|
2014-02-28 13:08:28 +01:00
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
# we show for completion either the (remaining) OPTIONS
|
|
|
|
|
# (if the current word starts with a dash) or the OBJECT list
|
|
|
|
|
# otherwise.
|
|
|
|
|
if [[ "${words[0]:0:1}" != '-' ]]; then
|
2015-03-27 13:11:06 +01:00
|
|
|
OPTIONS=(help general networking radio connection device agent monitor)
|
2014-02-28 13:08:28 +01:00
|
|
|
elif [[ "${words[0]:1:1}" == '-' || "${words[0]}" == "-" ]]; then
|
|
|
|
|
OPTIONS=("${LONG_OPTIONS[@]/#/--}")
|
|
|
|
|
else
|
|
|
|
|
OPTIONS=("${LONG_OPTIONS[@]/#/-}")
|
|
|
|
|
fi
|
|
|
|
|
_nmcli_list "${OPTIONS[*]}"
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
local command="${words[1]}"
|
2013-08-28 19:58:11 +02:00
|
|
|
case "${words[0]}" in
|
2013-08-21 18:55:11 +02:00
|
|
|
h|he|hel|help)
|
|
|
|
|
;;
|
|
|
|
|
g|ge|gen|gene|gener|genera|general)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 2 ]]; then
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND "$command" status permissions logging hostname
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 2 ]]; then
|
|
|
|
|
case "$command" in
|
2013-11-11 15:31:24 +01:00
|
|
|
ho|hos|host|hostn|hostna|hostnam|hostname)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" \
|
2014-01-10 00:52:58 +01:00
|
|
|
"$(printf '%s\n%s\n%s\n' \
|
2013-11-11 15:31:24 +01:00
|
|
|
"$(nmcli general hostname 2>/dev/null)" \
|
|
|
|
|
"$(cat /etc/hostname 2>/dev/null)" \
|
|
|
|
|
"$(hostnamectl status 2>/dev/null | sed -n '1s/^.\+hostname: \(.\+\)$/\1/p')" \
|
|
|
|
|
"$HOSTNAME")"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-21 18:55:11 +02:00
|
|
|
l|lo|log|logg|loggi|loggin|logging)
|
2014-01-10 00:52:58 +01:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND "${words[2]}" level domains
|
2014-01-10 00:52:58 +01:00
|
|
|
else
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-01-10 00:52:58 +01:00
|
|
|
OPTIONS=(level domains)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS
|
2014-01-10 00:52:58 +01:00
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2014-11-06 10:33:40 +01:00
|
|
|
s|st|sta|stat|statu|status| \
|
|
|
|
|
p|pe|per|perm|permi|permis|permiss|permissi|permissio|permission|permissions)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND "${words[2]}"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-21 18:55:11 +02:00
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
n|ne|net|netw|netwo|networ|network|networki|networkin|networking)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 2 ]]; then
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND "$command" on off connectivity
|
2013-09-12 16:19:42 +02:00
|
|
|
elif [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
case "$command" in
|
|
|
|
|
c|co|con|conn|conne|connec|connect|connecti|connectiv|connectivi|connectivit|connectivity)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND "${words[2]}" "check"
|
2013-09-12 16:19:42 +02:00
|
|
|
;;
|
|
|
|
|
esac
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
r|ra|rad|radi|radio)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 2 ]]; then
|
wimax: drop WiMAX support (bgo #747846)
Even Fedora is no longer shipping the WiMAX SDK, so it's likely we'll
eventually accidentally break some of the code in src/devices/wimax/
(if we haven't already). Discussion on the list showed a consensus for
dropping support for WiMAX.
So, remove the SDK checks from configure.ac, remove the WiMAX device
plugin and associated manager support, and deprecate all the APIs.
For compatibility reasons, it is still possible to create and save
WiMAX connections, to toggle the software WiMAX rfkill state, and to
change the "WIMAX" log level, although none of these have any effect,
since no NMDeviceWimax will ever be created.
nmcli was only compiling in support for most WiMAX operations when NM
as a whole was built with WiMAX support, so that code has been removed
now as well. (It is still possible to use nmcli to create and edit
WiMAX connections, but those connections will never be activatable.)
2015-04-13 17:07:00 -04:00
|
|
|
_nmcli_compl_COMMAND "$command" all wifi wwan
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
case "$command" in
|
wimax: drop WiMAX support (bgo #747846)
Even Fedora is no longer shipping the WiMAX SDK, so it's likely we'll
eventually accidentally break some of the code in src/devices/wimax/
(if we haven't already). Discussion on the list showed a consensus for
dropping support for WiMAX.
So, remove the SDK checks from configure.ac, remove the WiMAX device
plugin and associated manager support, and deprecate all the APIs.
For compatibility reasons, it is still possible to create and save
WiMAX connections, to toggle the software WiMAX rfkill state, and to
change the "WIMAX" log level, although none of these have any effect,
since no NMDeviceWimax will ever be created.
nmcli was only compiling in support for most WiMAX operations when NM
as a whole was built with WiMAX support, so that code has been removed
now as well. (It is still possible to use nmcli to create and edit
WiMAX connections, but those connections will never be activatable.)
2015-04-13 17:07:00 -04:00
|
|
|
a|al|all | w|wi|wif|wifi | ww|wwa|wwan)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND "${words[2]}" "on off"
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
c|co|con|conn|conne|connec|connect|connecti|connectio|connection)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 2 ]]; then
|
2015-11-24 14:14:53 +01:00
|
|
|
_nmcli_compl_COMMAND "$command" show up down add modify clone edit delete monitor reload load import export
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 2 ]]; then
|
|
|
|
|
case "$command" in
|
2013-08-21 18:55:11 +02:00
|
|
|
s|sh|sho|show)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2015-12-04 13:29:42 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME)")" active order
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-03-02 15:49:22 +01:00
|
|
|
|
2015-12-04 13:29:42 +01:00
|
|
|
LONG_OPTIONS=(help active order)
|
2014-03-02 15:49:22 +01:00
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
i=$?
|
|
|
|
|
|
|
|
|
|
if ! _nmcli_array_has_value LONG_OPTIONS active; then
|
|
|
|
|
COMMAND_CONNECTION_ACTIVE=1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
case $i in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
if [[ "x$COMMAND_CONNECTION_ACTIVE" = x ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME --active)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
2013-08-09 16:43:36 +02:00
|
|
|
;;
|
2013-08-21 18:55:11 +02:00
|
|
|
esac
|
2014-03-02 15:49:22 +01:00
|
|
|
|
|
|
|
|
OPTIONS=(id uuid path apath)
|
2014-01-17 20:02:51 +01:00
|
|
|
while [[ ${#words[@]} -gt 0 ]]; do
|
|
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
|
|
|
|
done
|
|
|
|
|
if [[ "x$COMMAND_CONNECTION_ACTIVE" = x ]]; then
|
|
|
|
|
_nmcli_list_nl "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME)")"
|
|
|
|
|
else
|
|
|
|
|
_nmcli_list_nl "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME --active)")"
|
|
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
u|up)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "ifname\nid\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-03-02 15:49:22 +01:00
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help)
|
|
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "ifname\nid\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
local COMMAND_CONNECTION_TYPE=''
|
2013-09-06 10:05:47 -05:00
|
|
|
OPTIONS=(ifname id uuid path)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
2013-09-06 10:05:47 -05:00
|
|
|
|
|
|
|
|
if [[ "$COMMAND_CONNECTION_TYPE" = "ifname" ]]; then
|
2014-10-14 15:53:34 +02:00
|
|
|
OPTIONS=(ap nsp passwd-file)
|
2013-09-06 10:05:47 -05:00
|
|
|
else
|
2014-10-14 15:53:34 +02:00
|
|
|
OPTIONS=(ifname ap nsp passwd-file)
|
2013-09-06 10:05:47 -05:00
|
|
|
fi
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
d|do|dow|down)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME --active)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-03-02 15:49:22 +01:00
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help)
|
|
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\napath\n%s" "$(_nmcli_con_show NAME --active)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
OPTIONS=(id uuid path apath)
|
2014-01-17 20:02:51 +01:00
|
|
|
COMMAND_CONNECTION_ACTIVE=1
|
2014-03-02 15:49:22 +01:00
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
|
|
|
|
a|ad|add)
|
2016-06-23 14:44:43 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(nmcli --complete-args connection add "" 2>/dev/null)"
|
|
|
|
|
else
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
_nmcli_list_nl "$(nmcli --complete-args connection add "${words[@]}" 2>/dev/null)"
|
|
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
|
|
|
|
e|ed|edi|edit)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\ntype\ncon-name\n%s" "$(_nmcli_con_show NAME)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-03-02 15:49:22 +01:00
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help)
|
|
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\ntype\ncon-name\n%s" "$(_nmcli_con_show NAME)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ "${words[0]}" = 'type' || "${words[0]}" = 'con-name' ]]; then
|
|
|
|
|
OPTIONS=(type con-name)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS
|
2013-08-28 19:58:11 +02:00
|
|
|
else
|
|
|
|
|
OPTIONS=(id uuid path apath)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS_CONNECTION
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
|
|
|
|
m|mo|mod|modi|modif|modify)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-02-28 13:37:25 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")" temporary
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-02-28 13:37:25 +01:00
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help temporary)
|
2014-03-01 01:51:34 +01:00
|
|
|
HELP_ONLY_AS_FIRST=1
|
2014-02-28 13:37:25 +01:00
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
2014-03-01 01:51:34 +01:00
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
2014-02-28 13:37:25 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2014-12-22 12:35:38 +01:00
|
|
|
OPTIONS=(id uuid path)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
2014-12-01 15:20:48 +01:00
|
|
|
|
2015-07-01 11:38:52 +02:00
|
|
|
_nmcli_compl_PROPERTIES ${COMMAND_CONNECTION_TYPE} "$COMMAND_CONNECTION_ID"
|
|
|
|
|
|
2014-02-28 13:52:58 +01:00
|
|
|
return 0
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2015-11-05 12:03:49 +01:00
|
|
|
c|cl|clo|clon|clone)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")" temporary
|
|
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help temporary)
|
|
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
OPTIONS=(id uuid path)
|
|
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
|
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
|
2015-03-27 13:11:06 +01:00
|
|
|
de|del|dele|delet|delete| \
|
2016-03-10 10:18:41 +01:00
|
|
|
mon|moni|monit|monito|monitor)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-17 20:02:51 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 1
|
2014-02-28 14:13:43 +01:00
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help)
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
2014-03-01 00:35:15 +01:00
|
|
|
if ! _nmcli_array_has_value LONG_OPTIONS "help"; then
|
2014-02-28 14:13:43 +01:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2013-08-28 19:58:11 +02:00
|
|
|
OPTIONS=(id uuid path apath)
|
2014-02-28 14:13:43 +01:00
|
|
|
while [[ ${#words[@]} -gt 0 ]]; do
|
|
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
|
|
|
|
done
|
|
|
|
|
_nmcli_list_nl "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2013-11-04 15:00:49 +01:00
|
|
|
l|lo|loa|load)
|
|
|
|
|
if [[ ${#words[@]} -gt 2 ]]; then
|
2014-01-10 00:52:58 +01:00
|
|
|
# we should also complete for help/--help, but who to mix that
|
|
|
|
|
# with file name completion?
|
2013-11-04 15:00:49 +01:00
|
|
|
compopt -o default
|
|
|
|
|
COMPREPLY=()
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-11-23 17:21:02 +01:00
|
|
|
i|im|imp|impo|impor|import)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND "${words[2]}" type file --temporary
|
|
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help temporary)
|
|
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND "${words[2]}" type file
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
OPTIONS=(type file)
|
|
|
|
|
OPTIONS_MANDATORY=(type file)
|
2016-05-19 09:40:44 +02:00
|
|
|
_nmcli_compl_ARGS type:vpn-type
|
2015-11-23 17:21:02 +01:00
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-11-24 14:14:53 +01:00
|
|
|
e|ex|exp|expo|expor|export)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")"
|
|
|
|
|
elif [[ ${#words[@]} -gt 3 ]]; then
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
|
|
|
|
|
LONG_OPTIONS=(help)
|
|
|
|
|
HELP_ONLY_AS_FIRST=1
|
|
|
|
|
_nmcli_compl_OPTIONS
|
|
|
|
|
case $? in
|
|
|
|
|
0)
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
1)
|
|
|
|
|
if [[ "$HELP_ONLY_AS_FIRST" == 1 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "id\nuuid\npath\n%s" "$(_nmcli_con_show NAME)")" "${LONG_OPTIONS[@]}"
|
|
|
|
|
fi
|
|
|
|
|
return 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
OPTIONS=(id uuid path)
|
|
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-11-23 17:21:02 +01:00
|
|
|
|
2013-08-21 18:55:11 +02:00
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
d|de|dev|devi|devic|device)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 2 ]]; then
|
2016-06-22 18:25:48 +02:00
|
|
|
_nmcli_compl_COMMAND "$command" status show connect reapply modify disconnect delete monitor wifi set lldp
|
2013-08-28 19:58:11 +02:00
|
|
|
elif [[ ${#words[@]} -gt 2 ]]; then
|
|
|
|
|
case "$command" in
|
|
|
|
|
s|st|sta|stat|statu|status)
|
2014-01-10 00:52:58 +01:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND "${words[2]}"
|
2014-01-10 00:52:58 +01:00
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2013-08-28 19:58:11 +02:00
|
|
|
sh|sho|show| \
|
2016-04-30 14:14:31 +02:00
|
|
|
r|re|rea|reap|reapp|reappl|reapply| \
|
2015-03-11 19:10:58 +01:00
|
|
|
c|co|con|conn|conne|connec|connect)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(_nmcli_dev_status DEVICE)"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2016-06-22 18:25:48 +02:00
|
|
|
mod|modi|modif|modify)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(nmcli --complete-args device modify "" 2>/dev/null)"
|
|
|
|
|
else
|
|
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
_nmcli_list_nl "$(nmcli --complete-args device modify "${words[@]}" 2>/dev/null)"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2014-06-19 11:25:17 +02:00
|
|
|
d|di|dis|disc|disco|discon|disconn|disconne|disconnec|disconnect| \
|
2015-03-27 13:11:06 +01:00
|
|
|
de|del|dele|delet|delete| \
|
|
|
|
|
m|mo|mon|moni|monit|monito|monitor)
|
2015-03-11 19:10:58 +01:00
|
|
|
if [[ ${#words[@]} -ge 3 ]]; then
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(_nmcli_dev_status DEVICE)"
|
2013-08-21 18:55:11 +02:00
|
|
|
fi
|
|
|
|
|
;;
|
2015-03-23 14:11:43 +01:00
|
|
|
se|set)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2015-09-21 18:24:17 +02:00
|
|
|
_nmcli_compl_COMMAND_nl "${words[2]}" "$(printf "ifname\n%s" "$(_nmcli_dev_status DEVICE)")"
|
2015-03-23 14:11:43 +01:00
|
|
|
else
|
2015-09-18 10:49:19 +02:00
|
|
|
_nmcli_array_delete_at words 0 1
|
|
|
|
|
OPTIONS=(ifname)
|
|
|
|
|
_nmcli_compl_ARGS_CONNECTION && return 0
|
2015-03-23 14:11:43 +01:00
|
|
|
OPTIONS=(autoconnect managed)
|
|
|
|
|
_nmcli_compl_ARGS
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-21 18:55:11 +02:00
|
|
|
w|wi|wif|wifi)
|
2013-08-28 19:58:11 +02:00
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
2015-10-02 22:46:53 +02:00
|
|
|
_nmcli_compl_COMMAND "${words[2]}" list connect hotspot rescan
|
2013-08-28 19:58:11 +02:00
|
|
|
else
|
|
|
|
|
case "${words[2]}" in
|
|
|
|
|
l|li|lis|list)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 2
|
2013-08-28 19:58:11 +02:00
|
|
|
OPTIONS=(ifname bssid)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS
|
2013-08-28 19:58:11 +02:00
|
|
|
;;
|
|
|
|
|
c|co|con|conn|conne|connec|connect)
|
|
|
|
|
if [[ ${#words[@]} -eq 4 ]]; then
|
|
|
|
|
if [[ "${words[3]}" = "" ]]; then
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(_nmcli_wifi_list SSID)"
|
2013-08-28 19:58:11 +02:00
|
|
|
else
|
2014-01-10 00:49:36 +01:00
|
|
|
_nmcli_list_nl "$(printf "%s\n%s" "$(_nmcli_wifi_list SSID)" "$(_nmcli_wifi_list BSSID)")"
|
2013-08-28 19:58:11 +02:00
|
|
|
fi
|
2013-08-09 16:43:36 +02:00
|
|
|
else
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 3
|
2015-07-10 13:16:21 +02:00
|
|
|
local OPTIONS=(password wep-key-type ifname bssid name private hidden)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS
|
2013-08-09 16:43:36 +02:00
|
|
|
fi
|
2013-08-28 19:58:11 +02:00
|
|
|
;;
|
2015-10-02 22:46:53 +02:00
|
|
|
h|ho|hot|hots|hotsp|hotspo|hotspot)
|
|
|
|
|
_nmcli_array_delete_at words 0 2
|
2015-12-04 13:29:42 +01:00
|
|
|
OPTIONS=(ifname con-name ssid band channel password)
|
2015-10-02 22:46:53 +02:00
|
|
|
_nmcli_compl_ARGS
|
|
|
|
|
;;
|
2013-08-28 19:58:11 +02:00
|
|
|
r|re|res|resc|resca|rescan)
|
2014-03-01 00:35:15 +01:00
|
|
|
_nmcli_array_delete_at words 0 2
|
2015-07-14 09:50:56 +02:00
|
|
|
OPTIONS_REPEATABLE=(ssid)
|
|
|
|
|
OPTIONS=(ifname ssid)
|
2014-01-10 11:40:11 +01:00
|
|
|
_nmcli_compl_ARGS
|
2013-08-28 19:58:11 +02:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
2013-08-21 18:55:11 +02:00
|
|
|
;;
|
2015-11-10 14:06:02 +01:00
|
|
|
l|ll|lld|lldp)
|
|
|
|
|
if [[ ${#words[@]} -eq 3 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND "${words[2]}" list
|
|
|
|
|
else
|
|
|
|
|
case "${words[2]}" in
|
|
|
|
|
l|li|lis|list)
|
|
|
|
|
_nmcli_array_delete_at words 0 2
|
|
|
|
|
OPTIONS=(ifname)
|
|
|
|
|
_nmcli_compl_ARGS
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2013-08-21 18:55:11 +02:00
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2014-10-30 15:45:43 +01:00
|
|
|
a|ag|age|agen|agent)
|
|
|
|
|
if [[ ${#words[@]} -eq 2 ]]; then
|
|
|
|
|
_nmcli_compl_COMMAND "$command" secret polkit all
|
|
|
|
|
fi
|
|
|
|
|
;;
|
2015-03-27 13:11:06 +01:00
|
|
|
m|mo|mon|moni|monit|monito|monitor)
|
|
|
|
|
;;
|
2013-08-21 18:55:11 +02:00
|
|
|
esac
|
2013-02-17 02:07:36 +01:00
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
} &&
|
|
|
|
|
complete -F _nmcli nmcli
|
|
|
|
|
|
|
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|