In bash, it's easy enough to set up customized completion of command arguments using the complete
built-in. For example, if, for a hypothetical command with a synopsis of foo --a | --b | --c
, you could do complete -W '--a --b --c' foo
You can also customize the completion you get when you press Tab at an empty prompt using complete -E
, e.g., complete -E -W 'foo bar'
. Then pressing tab at the empty prompt would suggest only foo
and bar
.
How do I customize command completion at a non-empty prompt? E.g., if I'm sitting at:
anthony@Zia:~$ f
how do customize completion so pressing tab would always complete to foo
?
(The actual case I'd like is loc
TAB → localc
. And my brother, who prompted me to ask this, wants it with mplayer).
loc
tolocalc
? I suggest alternatives because after quite some time digging and searching I have not found a way to customize bash completion this way. It may not be possible. – jw013 Aug 5 '14 at 20:47locate
,locale
,lockfile
or any of the other expansions ofloc
. Perhaps a better approach would be to map a different key to that specific completion. – terdon♦ Oct 28 '14 at 18:00lock<TAB>
orloca<TAB>
to avoidloc<TAB>
->localc
. But I'd actually like to make it context-sensitive, which is why programmable completion would be nice... – derobert Oct 28 '14 at 19:43