4

Is it possible to have a second configuration for Bash's complete which operates independently of the standard TAB triggered one?

I've written a Bash filename completion script tailored specifically for my purposes but I do not want to replace TAB completion with it. Instead I'd like to map it to different keys (e.g. Ctrl+F or an F# key) so that I can use it easily when needed but continue to use TAB completion most of the time.

At the moment I have a line in my .bashrc for testing my script which works fine:

complete -o nospace -o filenames -C /path/to/complete_script commands_list 

How do I configure custom keys to trigger my completion script without interfering with TAB completion?

1 Answer 1

2

If your custom completion is designed only for commands_list, this should work: bind complete command to a second key combination, and check value of $COMP_KEY in your script (this is a decimal character code of last character in the key sequence). If it's 9 (regular tab), do the default filename completion.

1
  • Thanks for your reply. If it is a tab how do I perform the default filename completion? i.e. Pass the completion back to Bash to handle. Commented Jul 19, 2019 at 10:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.