I use tab completion more than typing letters. I used to type rm ~/De<TAB> and it would be completed to rm ~/Desktop/ so that I could continue on the next level.

Recently, that behaviour changed. The completion now yields rm ~/Desktop<SPACE>, which means I must backspace and type the slash if I want to continue. This makes me cry.

The changes seem to be located in the function _longopt() in /etc/bash_completion, however that is as far as I can follow. Is this change intentional, and if so, what is it good for? Can I have the old behaviour back, preferably by a config option instead of just copying the old code over from some other system?

Edit: The function for reference.

    local cur prev split=false
    _get_comp_words_by_ref -n = cur prev

    _split_longopt && split=true

    case "$prev" in
            _filedir -d
            return 0
            return 0

    $split && return 0

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
            sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}\).*/\1/p' | sort -u )" \
            -- "$cur" ) )
    elif [[ "$1" == @(mk|rm)dir ]]; then
        _filedir -d
  • The only way I could see that this would make sense is if ~/Desktop is a file or an empty directory. And in the second case, that's only useful for commands like rmdir, not for mkdir or touch.
    – l0b0
    May 10, 2011 at 8:08
  • Could you post the body of your _longopt() function? May 10, 2011 at 8:58
  • @MPi: be aware that completion could depends on the command (first word of the command line). Also it can depends on readline settings (have you a ~/inputrc file?) and on the fact that the item is a real directory or a symlink to a directory.
    – enzotib
    May 10, 2011 at 9:24
  • Of course the completion depends on the first word of the line. Which is why I sometimes use a fantasy command to trick completion, and only change it to the real command before I send it. And I have no .inputrc on this system anymore. (Those were the days, fixing backspace and cursor keys…) And it happens for all elements, directory or file, symlink or not.
    – MPi
    May 10, 2011 at 11:11
  • 1
    Excellent question, I've observed the exact same behaviour, and it annoys me. No idea about the reason, though.
    – Christoph
    May 10, 2011 at 11:14

3 Answers 3


This is a known bug. See this LP question and these bugs 1 2.

This comment seems to be the fix. If you can't wait for a fix to trickle down the normal channels, edit /etc/bash_completion line 1587, change default to filenames (make a backup first).

  • 3
    Summary: It is a bug, you can fix it locally until the patch arrives by editing /etc/bash_completion line 1587, change default to filenames.
    – MPi
    May 10, 2011 at 11:47
  • edited my anwer
    – Christoph
    May 10, 2011 at 11:57
  • The comment that you've linked to no longer exists. Is your answer a complete summary of the linked solution?
    – Lou
    Nov 10, 2020 at 11:15
  • The bug got transferred to another package; see bugs.launchpad.net/ubuntu/+source/acroread/+bug/769866/comments/… but confirm that this is still relevant, probably a lot of things have changed in the meantime
    – Christoph
    Nov 11, 2020 at 7:47

I had, and solved, the same problem after installing Adobe Reader on Ubuntu 12.04.

I commented out the _filedir block in /etc/bash_completion.d/acroread.sh and it worked normally again.

  • As of today's date this is what worked for me as well. Mar 26, 2013 at 5:52
  • 1
    Same here: acroread triggered it and commenting out the _filedir block (right on top) fixed it. You have to log out or run 'exec bash' in all your shells to see the effect, see this question.
    – dirkjot
    Jun 14, 2013 at 20:37

I had the same problem and I fixed it by removing /etc/bash_completion.d/ directory, then reinstall bash_completion. I guess an old file was in this directory... Hopefully it will solve your problem too.

  • like this guy: timlabath.com/words/2011/05/10/…
    – type
    May 18, 2011 at 14:37
  • 2
    This – indeed – fixed it. However, that method es much too radical, as it throws away many completions. After deleting the package bash-completion, one of the files remaining /etc/bash_completion.d/ must be the culprit. It was acroread.sh in my case – it redefines _filedir.
    – MPi
    Jun 6, 2011 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .