I use bash on both my Mac and as my cygwin shell. Overall, I'm quite pleased with it.

My one complaint however is that its TAB completion isn't as good as Windows Command Line TAB completion.

For example, if there are two files with the same prefix, then bash just beeps at me when I try to TAB complete. If I keep nailing TAB, then it will eventually show me a list of potential files.

I definately prefer how Windows will cycle through potential files right on the command line.

Is there a way to get bash to operate similar to Windows Command Line in this regard?

If there isn't (I do not want to switch shells), am I missing something about TAB completion in bash? Is there a more efficient way to use it?

up vote 41 down vote accepted

To get the ‘cycle through possible completions’ behavior, copy the following into an appropriate place in your .bashrc file:

[[ $- = *i* ]] && bind TAB:menu-complete

Also, bash-completion provides many extra kinds of completion besides just pathname completion. For example, menu-complete works fine with Git's bash-completion module to complete command names, option names, etc.

  • what is the procedure to do this for OSx terminal? – Alex Nov 30 '11 at 14:19
  • 2
    @Alex: You edit the file .bashrc in your home directory so that it contains the specified line. If your .bash_profile file (in the same directory) does not also have a line like source ~/.bashrc, then you should also edit it to include such a line. The setting will be active in new Terminal windows. If you do not have a preferred editor, you can open the file in TextEdit with the command open -e ~/.bashrc; if the file does not yet exist, you will need to create it first with (e.g.) the command touch ~/.bashrc. – Chris Johnsen Dec 1 '11 at 2:46
  • 1
    @Alex, Bash is the default shell on 10.3 and later, including 10.7 (Lion). First echo $SHELL. That will be the shell selected for your user account. If that’s not what you want, you’ll need to change your shell with chpass -s /bin/bash (or whatever shell you want). If $SHELL is fine, then check Terminal > Preferences > Startup > Shells open with: and Terminal > Preferences > Settings > Profiles > Shell > Startup to see if the default user shell has been overridden with a custom command. – Chris Page Jun 14 '12 at 20:31
  • 5
    Does anyone have any idea what should I bind to go one option back with Shift + Tab? – ppp Jan 2 '14 at 8:12
  • 3
    @ppp in your .bashrc: bind '"\e[Z":menu-complete-backward' – vault Feb 23 '16 at 10:24

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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