From cc68b183144ab25786e4d00a0eabebafccb3e683 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 29 Sep 2024 14:54:30 +0100 Subject: [PATCH] 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? --- contrib/completion/bash-completion.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/completion/bash-completion.sh b/contrib/completion/bash-completion.sh index 3858baec..ed4b3a9a 100755 --- a/contrib/completion/bash-completion.sh +++ b/contrib/completion/bash-completion.sh @@ -61,10 +61,15 @@ function _resticprofile() { ;; esac fi + + if [[ ! "${COMPREPLY[*]}" == *. ]]; then + # Add space if the last character is not a '.' + compopt +o nospace + fi } # Registering the completion -complete -F _resticprofile resticprofile +complete -F _resticprofile -o nospace resticprofile # # __resticprofile_get_other_completions