lincheney / fzf-tab-completion

Tab completion using fzf
GNU General Public License v3.0
623 stars 40 forks source link

Unable to complete ${T<tab> outside of quotes #89

Open systemmonkey42 opened 7 months ago

systemmonkey42 commented 7 months ago

Outside of a quoted string, "${VAR" is split into "$" "{" and "VAR", and pressing TAB attempts filename completion on "VAR".

The following patch

@@ -14,7 +14,7 @@ _fzf_bash_completion_shell_split() {
     $_fzf_bash_completion_grep -E -o \
         -e '\|+|&+|<+|>+' \
         -e '[;(){}&\|]' \
-        -e "(\\\\.|[^\"'[:space:];(){}&\\|<>${wordbreaks}])+" \
+       -e "(\\\\.|\$\{[^}]*(\}|$)|[^\"'[:space:];(){}&\\|<>${wordbreaks}])+" \
         -e "\\\$'(\\\\.|[^'])*('|$)" \
         -e "'[^']*('|$)" \
         -e '"(\\.|\$($|[^(])|[^"$])*("|$)' \

seems to help, but I'm sure there are unintended side effects.

lincheney commented 5 months ago

i've made a basic fix here https://github.com/lincheney/fzf-tab-completion/commit/62c49fb10f16db3d855586382e91066d2cea9c93 But it won't handle more complicated cases, like ${var:-${another_var