3

When I attempt to tab-autocomplete an ls directory name, the autocomplete does not give the slash that allows me to type the next subdirectory. Instead, it gives me a space, making me have to backspace and add a slash before proceeding. e.g., If I'm at the root of a directory with the structure dir1/dir2/dir3/test.txt, and I type ls di [tab], I get ls dir1  when I want ls dir1/.

For some other commands I use with autocomplete, this does not occur, such as cd. However, it also does occur with others. e.g., I use a visualization program called VMD, and when I want to run a script with VMD I would type vmd -e dir/scriptname.tcl. If I tried to autocomplete the directory leading to the script, the same issue occurs as with ls.

I have the bash-completion package properly installed. When I type complete -p | grep " ls", I get complete -F _longopt ls

If I type complete -d ls, then autocomplete works correctly for the rest of the session. It's bizarre to me that I'd need to add that to my .bashrc file though. This issue is only coming up for me on one particular Ubuntu workstation of mine and is not present on other ones. Any ideas what might be causing this?

FYI, my .bashrc file already contains:

if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

Nothing else in my .bashrc file related to autocompletion.

  • What happens if you type in ls and try to double tap for auto completion is everything listed as a file or does it recognize your dir's with a / at the end? – Ziazis Jul 6 '17 at 11:27
  • When I type ls [tab], everything is listed without a / at the end (presumably as a file). If I do complete -d ls and then ls [tab], only directories get listed, and with the / at the end. – efremdan1 Jul 6 '17 at 12:09
  • And of course you're right that that is the root of the problem. On my other workstation, I get the same result from complete -p | grep " ls", but ls [tab] shows the directories with slashes at the end. So why is my computer not recognizing the directories as directories? – efremdan1 Jul 6 '17 at 12:53
  • Well, just try copying the files /etc/bash_completion and /usr/share/bash-completion/bash_completion from the ones which work to the one that is not working. – Ziazis Jul 6 '17 at 12:57
  • They were the same, but I found that in /etc/bash_completion.d, there was an extra file in the one that wasn't working called "isaacs", which got put there when I installed the program from isaacs.sourceforge.net/index.html. Of course, removing it fixed everything. Thanks Ziazis! If you want to put that answer, I can mark it as correct to give you the points :) – efremdan1 Jul 6 '17 at 13:18
2

You might need to crosscheck the broken files with some that work.

Necessary files/dirs would be:

/etc/bash_completion, /usr/share/bash-completion and /etc/bash_completion.d

Once you've found the culprit adjust the files/remove unnecessary files to fix it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.