Tab completion isn't working

Does anyone know of a reason that tab completion for a file name won’t work when I start out with either " or '? It will get part of the name but not all of it. An example is I need to complete this filename: Kirsty Lee Akers - Burn Baby Burn. When I type Kirsty and hit tab it will complete the Kirsty Lee Akers but not the rest of it. If I don’t try to put quotes around it it will complete the entire folder name.

After some experimenting I have found the completion will work when trying to cd into the folder, both with quotes and without. It just doesn’t work when trying to complete it from within a command.

Have you bash-completion installed?

As far as I know it is installed.

Would you happen to have a file beginning the same way from the same parent folder?

No. And hitting tab twice does not show me suggestions.

I have the same results @peaveyman on Manjaro when using tab completion and globbing characters.

Test data: touch "Kirsty Lee Akers - Burn Baby Burn"

Test1: Type ls K?*[tab] # tab completion does not work
Glob Characters:
?: Match any single character
*: Matches any string

Type: complete -r

Test2: Recall Test1 # tab completion works

I tried complete -r ls and then repeated Test1, but that didn’t work.

Knowns:

  1. The completion:
    complete -p ls
    output: complete -F _longopt ls

  2. The location:
    /usr/share/bash-completion/bash-completion
    Sourced in /etc/bashrc.

  3. pacman -Qi bash-complettion
    Packager archlinux

  4. Doc:
    command line: help complete
    https://wiki.archlinux.org/index.php/Bash#Tab_completion
    https://github.com/scop/bash-completion

  5. set -x on the command line can be used for debugging.

The solution unknown :slight_smile: I tried this test on another distro (LM/Bash v4, Suse/Bash v5) and it works.

Are you sure you’re using bash? (the reason I ask is the gnome desktop version of manjaro recently switch over to Zsh as the default shell). I personally use fish and the tab completion might behave differently for the different shells (which is why the behavior on the other system you use might be giving you different results then when you try it on your manjaro system.)

Anyway if you type:

echo $SHELL

That will tell you which shell you are using (you can do that on the system where the tab completion is working the way you want it to to see what shell you are using on that system as well. As far as changing your default shell you can do the following:

cat /etc/shells

that will provide you with a list of your shells installed on your system for example the output of that command on my system looks like the following:

/bin/sh
/bin/bash
/bin/zsh
/usr/bin/zsh
/usr/bin/git-shell
/usr/bin/fish
/bin/fish

So in this example if your user login account name was peaveyman for example you would type the following to set bash as your user’s shell.

chsh --shell /bin/bash peaveyman
1 Like

Good point. I’m using bash on XFCE. I assumed :slight_smile: OP was bash. I hope my specific repeatable example, although not exact, reflects the OP problem. I have noticed some strangeness (different or unexpected :slight_smile: ), but have ignored them, plus I’d like to learn more about Tab Completion.

@peaveyman I assumed the ls command. If different, let the forum know.
Also, which desktop are you using? The more specific you can be with the commands you are using the more helpful. When you say, start out with '?, that means a literal question mark because it is in single quotes.

I created a directory Kirsty Lee Akers - Burn Baby Burn, and a couple of files starting with Ki and then did a ls "Ki[tab][tab] and all files were displayed. I tried it again with cd and [tab] and the directory was expanded.

When using glob characters, in my post above, I did have some luck with alt-g (glob-complete-word) instead of [tab].

Summary

I hope you find these additional resources helpful.

The chapter dealing with the command line in the Bash Reference is Chapter 8, “Command Line Editing”. I’ve always skimmed over it, but there is a lot of good info for advanced editing.
Bash Reference Manual

Section on Quoting:
Bash Reference Manual

Section on Pattern Matching. This special characters are known as globs (they aren’t regular expressions).
Bash Reference Manual