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 lo` + if [[ "$cur" =~ [[:space:]]+ ]]; then + cur='' + fi + _nmcli_complete_OPTIONS && return 0 local command="${words[1]}"