If I have a program located in /a/prog and /a is not in PATH, is it possible to specify a bash completion for running ./prog in /a so that it doesn't affect any other program named prog located anywhere else?
To clarify, here's an example:
_complete_prog() { [ "$COMP_CWORD" == 1 ] && \ COMPREPLY=($(compgen -W "aaa bbb" "${COMP_WORDS[1]}")) } complete -F _complete_prog ./prog This will make only the first argument of ./prog tab complete as follows
$ ./prog <TAB><TAB> aaa bbb I don't want this completion to apply for
./progif that's a different file, e.g./b/prog.I want for the same completion to apply for
/a/progand././progor any other path that leads to the same file.
./pr<tab>by expanding to./prog? By default,bashalready does that (ifproghas the executable bit set). Maybe you just need tochmod +x /a/progto get the behavior you want.