diff options
author | Thomas Haller <thaller@redhat.com> | 2013-11-13 14:38:13 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2013-11-13 14:42:59 +0100 |
commit | 93f5687d7b860bd0a0aba3b5ddce6542fec03923 (patch) | |
tree | 2816d95b42767bb16a217b83b8605ac11ee3907e | |
parent | ce370fab64c5bee739e6f3ad91fac427da0de43d (diff) | |
download | NetworkManager-93f5687d7b860bd0a0aba3b5ddce6542fec03923.tar.gz |
cli: fix bash completion for curser not at EOL
If the curser is not at the end of the line, we want to complete
by ignoring everything right of the curser. However, the variable
$cur is set to the spaces since the last word, so we have to
get rid of them first
Without this, the following did not complete:
$ nmcli connection modify id <TAB> lo
because $cur is set to ' '.
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | cli/completion/nmcli | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cli/completion/nmcli b/cli/completion/nmcli index 9f427ee10f..7f535bccf6 100644 --- a/cli/completion/nmcli +++ b/cli/completion/nmcli @@ -544,6 +544,13 @@ _nmcli() words[i]="$(echo "${words[i]}" | xargs 2>/dev/null || true)" done + # 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` + if [[ "$cur" =~ [[:space:]]+ ]]; then + cur='' + fi + _nmcli_complete_OPTIONS && return 0 local command="${words[1]}" |