Bash tab behavior changed

Over time, I got used to the fact that I can type something like:

$ opt / foo / m

etc. to navigate my project in different environments. This is really useful: just set up $ opt (say / home / $ USER / projects / opt - and go from your developer user to qa to live, and $ opt to $ opt.

Since bash4.2 was released, this behavior has changed. Now terminating the tab results in a shielded $ sign.

$ opt / foo => \ $ opt / foo <= is not at all what I had in mind!

While the attendants are discussing how this should work, I would like to find a new set of habits that I could use to return to my comfort zone. What would be a good trick? Something that my fingers could learn to set up the root from there, without worrying about where I am.

+4
source share
4 answers

The workarounds suggested here and elsewhere either failed at all for me or were too cumbersome to print.

In the end, a friend recommended using zshell (zsh). It is working! I did not make any settings, leaving my .zshrc empty.

Now I have returned the completion of my tab again. It works a little differently than I'm used to: combining the old bash style and vi style. By clicking on the tab, you can see a list of several parameters, then a tab will be added again, which will begin to select from this list and alternate, for example, vi.

I am very happy.

0
source

This is not ideal, but a workaround is to use ESC ctrl-e to force the variable to expand before clicking the tab (at least in emacs mode ... not sure about vi mode)

+1
source

Based on frankc's answer: try putting the following in ~/.inputrc :

 "TAB": "\M-\Ce\M-\Ct" "\M-\Ct": complete 

then launch a new shell. What does it do:

  • Changes the TAB key to insert two characters: ESC-Ctrl-e ESC-Ctrl-t.
  • Maps ESC-Ctrl-t for the complete function, which is usually called when TAB is pressed. (You can use any key combination instead of ESC-Ctrl-t, but this one is usually not used.)

Since ESC-Ctrl-e is already mapped to the shell-expand-line function, now when you press TAB, bash first expands your variable ( $opt ), then automatically terminates as usual.

0
source

The zsh solution is all that worked for me. This was a trivial conversion of my .bashrc => .zshrc, and I have some complex functions / pseudo-random functions.

I agree with how in the world supporting bash violated this very basic tab completion functionality.

Another solution that I have not tried uses bash from another distribution. I only saw this in the Mint 13 release. Ubuntu / Fedora bash works fine.

0
source

All Articles