I used to never rely on it, but now that I am hooked, this is driving me nutty. When I am in terminal and hit Tab to autocomplete my statement, it works for most commands (cd, mv, rm, etc) but it is broken for vim/vi. When I type vim Tab or anything similar, I get an error as soon as I hit tab:

bash: command substitution: line 905: syntax error near unexpected token `}'
bash: command substitution: line 905: `        }'

I would try to fix this myself, but I have no idea what file to even look in. I tried /usr/share/bash-completion/bash-completion, and it is one of the few files I have found related to the bash with more than 900 lines, but line 905 is dealing with IP addressing. Here it is, for the sake of being thorough:

-ne 's|.*inet[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p' )" \

Anyway, I tried installing the latest bash-completion from git, as suggested in How to fix corrupted bash-completion in command substitution?, but it didn't help. Closing and relaunching bash sometimes helps for a few s, and sudo -i causes it to work, but of course I don't want to stay logged in as su every time I need to edit some stuff. Any idea what file I need to look at to correct this thing?

EDIT: If I run bash inside the terminal, I see no immediate changes (colors remain the same, etc.) but I can Tab with vim. Of course, all of my aliases are also lost from my previous session, and if I execute a shell script from bash, it returns to the "outer" shell, thus causing the problem to arise again or forcing me to re-bash. It would really make my life easier if I could just fix the script that is malfunctioning here.


I think you’re on the right track Ronald. In you bash_completion file there is a function called _ip_address that has a variable assignment that spans five lines. Try checking yours against all five lines between line numbers 928 and 932 in the bash_completion file at THIS LINK. Spelling counts ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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