Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completition fail on function with an alias #115

Open
Anselmo95 opened this issue Jan 20, 2025 · 2 comments
Open

Tab completition fail on function with an alias #115

Anselmo95 opened this issue Jan 20, 2025 · 2 comments

Comments

@Anselmo95
Copy link

Hello,
I here are some details on my system and i did not do touch config apart what specified in the README for the installation.

> fzf --version 
0.58.0 (65db735)
# Last commit on my machine for fzf-tab-completion
> git log -1
commit 4850357beac6f8e37b66bd78ccf90008ea3de40b (HEAD -> master, origin/master, origin/HEAD)
Author: <[email protected]>
Date:   Mon Jan 20 18:47:37 2025 +1100

    let fzf take up more space if its available
 > bash --version
GNU bash, version 4.4.20(1)-release

I have the habit of using function within alias, for example:

alias untargzpdf='_untargzpdf(){
                            tar -xvzf $1 --wildcards '*.pdf';
                            unset -f _untargz;
                        }; _untargzpdf'

The autocompletion works for the alias itself but if I try to tab one more time to select a file it does not work and it gives me this error:

~/Programs/fzf-tab-completion/bash/fzf-bash-completion.sh: eval: line 447: syntax error near unexpected token `('
~/Programs/fzf-tab-completion/bash/fzf-bash-completion.sh: eval: line 447: `compspec=( complete -F _minimal _untargzpdf(){ )'
> untargzpdf

I guess this is probably some kind of corner case or what I usually do with alias is not really correct/orthodox 😅

Thanks

@lincheney
Copy link
Owner

oh that's intereseting, i think right now the code just naively takes the first "word" of the alias as the actual command, but yours is more complicated than that, would probably have to start doing the bash parsing on the alias

@Anselmo95
Copy link
Author

Ah ok, it make sense then why it's behaving this way but honestly I don't know if it is worth the time to add the alias parsing.

In the end I worked around the issue by defining just the function instead of the alias.
So just doing this works basically the same for me:

untargzpdf(){
                            tar -xvzf $1 --wildcards '*.pdf';
                        }

Thanks for the answer !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants