Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash tab completion adds extra space after the first completion

Tags:

Bash tab completion adds extra space after the first completion which stops further completion if the compeletion target is a file in multi-level folders.

For example, I have a file in the path ~/Documents/foo/bar.txt, and I want to list it. I face the following problem, when input

a@b:~$ls Docu <TAB> 

I get

a@b:~$ls Documents |(<-this is the cursor, so there is an extra space afer Documents) 

So I cannot further tab complete. I have to backspace to delete the extra space.

Normally I want to get:

a@b:~$ls Docu <TAB> a@b:~$ls Documents/ <TAB> a@b:~$ls Documents/foo/ <TAB> a@b:~$ls Documents/foo/bar.txt 
like image 248
shiquanwang Avatar asked Aug 16 '12 06:08

shiquanwang


People also ask

How does autocomplete work in bash?

The programmable completion feature in Bash permits typing a partial command, then pressing the [Tab] key to auto-complete the command sequence. [1] If multiple completions are possible, then [Tab] lists them all. Let's see how it works. Tab completion also works for variables and path names.

Does bash have tab completion?

Bash completion is a functionality through which Bash helps users type their commands more quickly and easily. It does this by presenting possible options when users press the Tab key while typing a command.

What is Shell tab completion?

Command-line completion (also tab completion) is a common feature of command-line interpreters, in which the program automatically fills in partially typed commands.


1 Answers

Just for the record: There is also a bug in the adobereader-enu (acroread) package that breaks bash completion. In this case you can just delete the symlink:

rm /etc/bash_completion.d/acroread.sh 

See also: https://bugs.launchpad.net/ubuntu/+source/acroread/+bug/769866

like image 189
tlo Avatar answered Sep 22 '22 06:09

tlo