1

How can I disable bash completion for everything except filesystem paths?

But even for paths, I don't want anything interpreted.

For example, if I do:

# sh -f fo<tab>

and there's a file foo.txt, it doesn't work whereas if the file were foo.sh it would. I assume bash is trying to "help" me here. I've been using Linux for a long time and I don't want bash completion to do anything that assumes to know what I'm thinking. I don't want it to look into zip files or guess hostnames. I just want plain path name completion and nothing else.

5
  • I think that's loaded in /etc/bash.bashrc. Can you check if that is the case in your distribution?
    – pfnuesel
    Nov 5, 2016 at 21:38
  • I think you have this backward. Any tab completion is assuming it knows what you're thinking. Are you really saying you don't want tab completion for commands?
    – Wildcard
    Nov 5, 2016 at 22:45
  • Can you settle these contradictory phrases? "even for paths, I don't want anything interpreted" and "I just want plain path name completion"
    – Jeff Schaller
    Nov 5, 2016 at 23:33
  • I suppose I do want command autocomplete. But if the default Fedora 24 profile configures complete to basically hide a file based on suffix, my faith in that component is lost. I want a "minimal" complete profile.
    – squarewav
    Nov 5, 2016 at 23:42
  • Completing something from a list is fine. But hiding a file based on suffix is too much interpretation.
    – squarewav
    Nov 5, 2016 at 23:50

1 Answer 1

2

bash has a builtin command complete which controls the autocomplete behavior of the current shell. It is possible that your distribution or sysadmin arranged to configure interactive shells by putting these complete commands into the configured startup files (traditionally /etc/profile, /etc/bash.bashrc, ~/bash_profile, ~/bash_login, ~/.profile, ~/.bashrc).

To permanently disable this feature, you can edit these files not to call these complete commands (or to call just the ones that you like).

To disable "intelligent" autocomplete just for one instance of interactive session, run

complete -r

in that session.

2
  • Ok, so complete -r does the trick. I suppose I can just set this in ~/.bash_profile? Am I loosing anything important by clearing everything like this. Path and command tab completion seems to work fine. I'm using Fedora at the moment (normally I use CentOS but this machine is new so I have to use one of the bleeding edge distros) which has all of the complete stuff in /usr/share/bash-completion/bash_completion.
    – squarewav
    Nov 5, 2016 at 23:34
  • 1
    @squarewav: I can't guess what is important for you; you can check yourself by complete -p to show what you would lose. As to complete -r in ~/bash_profile: it should do the trick, although it would not save you the time that the bash_completion script could consume during shell startup (it is noticable on my hardware); I would prefer editing the system-wide configuration instead if that's where /usr/share/bash-completion/bash_completion gets sourced.
    – trosos
    Nov 5, 2016 at 23:55

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.