alterx icon indicating copy to clipboard operation
alterx copied to clipboard

[feature] Add tab to autocomplete file name

Open pdelteil opened this issue 1 year ago • 2 comments

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

pdelteil avatar Aug 02 '24 21:08 pdelteil

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

dwisiswant0 avatar Aug 03 '24 02:08 dwisiswant0

Thank you.

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

pdelteil avatar Aug 03 '24 03:08 pdelteil