Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a bad habit of pressing TAB too many times when using the terminal. If whatever bash completion routine invoked is particularly slow, this causes a huge wait while the terminal shows me the completion list 2-3 times (or however many times TAB was pressed).

Is there a way to get bash completion to just ignore the repeated keypress(s)?

share|improve this question
3  
Note that you can interrupt auto-completion with Control-C. –  Chris Page Sep 24 '12 at 13:03
    
Repeated keypress(s) not sure if that's supported in bash. If you want to completely ignore auto-completion, you may check this link unix.stackexchange.com/questions/29494/… –  maneeshshetty Jan 21 '13 at 5:04
    
If you're not too hooked on bash, you might try another shell to see how its performance compares. I myself can't tell the difference, but the slowness might be specific to your file-system layout. Other shells on your system are listed in /etc/shells. All but /bin/sh have file completion. I use tcsh, which uses ctrl-D for non-unique command completion, but TAB as usual. To try out a different shell (IIRC, ksh is close to bash), just execute it at a command line; the prompt will change. See their man pages for specifics. –  Nevin Williams Apr 18 '13 at 15:21

1 Answer 1

The manual page defines a large set of "variables" that can be defined in your ~/.inputrc file to tweak the supported completion keys.

By strategically assigning the right key to the right function, you probably will get the effect you want. However, you cannot really prevent a double TAB from doing the work twice.

Sample ~/.inputrc file:

C-TAB: complete
TAB: complete-filename

The concern area in the manual page reads as follow:

Completing
   complete (TAB)
          Attempt  to  perform  completion on the text before point.  Bash attempts
          completion treating the text as a variable (if the text begins with $),
          username (if the text begins with ~), hostname (if the text begins with @),
          or command (including aliases and functions) in  turn.   If  none  of
          these produces a match, filename completion is attempted.
   possible-completions (M-?)
          List the possible completions of the text before point.
   insert-completions (M-*)
          Insert all completions of the text before point that would have been
          generated by possible-completions.
   menu-complete
          Similar  to  complete,  but  replaces  the word to be completed with a
          single match from the list of possible completions.  Repeated execution of
          menu-complete steps through the list of possible completions, inserting
          each match in turn.  At the end of the list of completions, the  bell  is
          rung  (subject  to  the  setting  of  bell-style)  and  the original text
          is restored.  An argument of n moves n positions forward in the list of
          matches; a negative argument may be used to move backward through the list.
          This command is intended to be bound  to  TAB,  but  is  unbound  by
          default.
   menu-complete-backward
          Identical  to menu-complete, but moves backward through the list of possible
          completions, as if menu-complete had been given a negative argument.
          This command is unbound by default.
   delete-char-or-list
          Deletes the character under the cursor if not at the beginning or end of
          the line (like delete-char).  If at the end of the line, behaves identi‐
          cally to possible-completions.  This command is unbound by default.
   complete-filename (M-/)
          Attempt filename completion on the text before point.
   possible-filename-completions (C-x /)
          List the possible completions of the text before point, treating it as
          a filename.
   complete-username (M-~)
          Attempt completion on the text before point, treating it as a username.
   possible-username-completions (C-x ~)
          List the possible completions of the text before point, treating it as
          a username.
   complete-variable (M-$)
          Attempt completion on the text before point, treating it as a shell variable.
   possible-variable-completions (C-x $)
          List the possible completions of the text before point, treating it as
          a shell variable.
   complete-hostname (M-@)
          Attempt completion on the text before point, treating it as a hostname.
   possible-hostname-completions (C-x @)
          List the possible completions of the text before point, treating it as
          a hostname.
   complete-command (M-!)
          Attempt  completion  on  the  text  before  point, treating it as a
          command name.  Command completion attempts to match the text against aliases,
          reserved words, shell functions, shell builtins, and finally executable
          filenames, in that order.
   possible-command-completions (C-x !)
          List the possible completions of the text before point, treating it as
          a command name.
   dynamic-complete-history (M-TAB)
          Attempt completion on the text before point, comparing the text against
          lines from the history list for possible completion matches.
   dabbrev-expand
          Attempt menu completion on the text before point, comparing the text
          against lines from the history list for possible completion matches.
   complete-into-braces (M-{)
          Perform filename completion and insert the list of possible completions
          enclosed within braces so the list is available to the shell  (see  Brace
          Expansion above).
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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