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

[feature] Add tab to autocomplete file name #170

Open
pdelteil opened this issue Aug 2, 2024 · 2 comments
Open

[feature] Add tab to autocomplete file name #170

pdelteil opened this issue Aug 2, 2024 · 2 comments

Comments

@pdelteil
Copy link

pdelteil commented Aug 2, 2024

While using -pp param it would be useful to have the tab autocomplete function to load the file name.

For instance, I want to use the file brute.force.txt into the param word here:

alterx -p '{{word}}.{{suffix}}' -pp word=brute.force.txt

@dwisiswant0
Copy link
Member

I think that's because the shell knows when to autocomplete paths usually when they come right after a command or flag. The shell treats "word=brute.for<TAB>" as a single string, so it doesn’t recognize it as a path that needs completing because it's mixed with other text ("word=").

For the workaround, you can set up a simple custom completion script for alterx to handle completions:

# if you're using Bash :)
_alterx_custom_completion() {
    local cur

    cur="${COMP_WORDS[COMP_CWORD]}"
    COMPREPLY=( $(compgen -f -- "$cur") )
}

complete -F _alterx_custom_completion alterx

@pdelteil
Copy link
Author

pdelteil commented Aug 3, 2024

Thank you.

Works good. But doing source .bashrc gave me a different result than closing the terminal and opening it again.

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