Skip to content

Commit f47f408

Browse files
committed
feat(bash-completion): prevent space after profile completion .
When tab completing a profile, an unwanted space is added after the period `.`, necessitating hitting backspace before further completions can be accessed. The implementation here was based on the following resources: * https://stackoverflow.com/a/66151065 - Add spaces to the end of some Bash autocomplete options, but not to others? * https://stackoverflow.com/a/19271994 - How can I check the last character in a string in bash? An alternative to checking for the last character is using regex: * https://stackoverflow.com/a/21425089 - How to check if the last string character equals '*' in Bash?
1 parent 4181d9e commit f47f408

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/completion/bash-completion.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ function _resticprofile() {
6161
;;
6262
esac
6363
fi
64+
65+
if [[ ! "${COMPREPLY[@]}" == *. ]]; then
66+
# Add space if the last character is not a '.'
67+
compopt +o nospace
68+
fi
6469
}
6570

6671
# Registering the completion
67-
complete -F _resticprofile resticprofile
72+
complete -F _resticprofile -o nospace resticprofile
6873

6974
#
7075
# __resticprofile_get_other_completions

0 commit comments

Comments
 (0)