Is it possible to disable bash's autocomplete on pressing tab?

The reason I want to do this is that I often paste code from an editor where I use the tab character instead of a number of spaces for indention, into my terminal.

And no, you can't convince me to use spaces instead of tabs.

  • In zsh, the Tab key inserts a tab if you press it at the beginning of a line (before any non-whitespace character). I don't think bash can be programmed for that (you can bind a key to a bash function, but AFAIK you can't trigger a completion from that bash function). Jan 21, 2012 at 14:39

4 Answers 4



 set disable-completion on

string in ~/.inputrc and restart your shell. it will disable completion at all.

  • not only in bash though...
    – yrk
    Jan 19, 2012 at 20:07
  • 8
    To have it only affect Bash, instead of including that line in your ~/.inputrc file, add this to the appropriate shell startup file: bind 'set disable-completion on' Jan 19, 2012 at 20:13
  • 1
    What Dennis said, and the appropriate startup file is ~/.bashrc (if it doesn't take in login shells, add source ~/.bashrc to ~/.bash_profile). Jan 20, 2012 at 22:51
  • disable-completion is a readline option, not a bash option. As far as I can check, it does not disable tab completion when copying code to a bash shell.
    – db-inf
    Nov 16, 2021 at 22:58

Dennis' solution

bind 'set disable-completion on'

can be done on the fly in Bash as well. You do not need to put it in .bashrc.

Musta's solution (bash --noediting) works but also disables command line editing.

Another way is

bind -u complete

(unset key binding associated with 'complete')

http://www.gnu.org/software/bash/manual/bashref.html, 4.2 Bash Builtin Commands.

  • The correct answer for the question "how do I temporarily disable Bash completion?" This helps a lot when you're navigating through a directory with 81,000+ files and you can't even Ctrl+C without waiting two minutes for Bash to come back with a prompt. Nov 21, 2018 at 23:07

To disable Bash tab completion only temporarily you can start a Bash with the --noediting option:

alias noed='bash --noediting'

With terminals supporting bracketed paste (i.e. most modern terminals) you can run bind 'set enable-bracketed-paste on' to skip readline handling of the pasted code:

user@host:~$ bind 'set enable-bracketed-paste off'
user@host:~$ STR="Foo
Display all 2376 possibilities? (y or n)^C
user@host:~$ bind 'set enable-bracketed-paste on' 
user@host:~$ STR="Foo

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.