Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to have bash autocomplete matching symbols like '"[{( with their right handed counterparts? I would like to do this without having to press tab.

For example typing the string echo " would immediately result in this string echo "|", where my cursor (the pipe) is in between the two quotes.

Bonus points if you can find a way that, when the first quote is deleted, the second one is also deleted.

If you've ever used any mature text editor (eg. sublime text), you can understand how this interaction works. Answers utilizing fish shell are also accepted.

share|improve this question

Although you can not bind keys on itself in GNU Readline — something like "(": "()" drives to endless loop — there is a way. Not for readline in general, only for bash. Add this to you .bashrc:

readline-brackets() {
bind -m vi-insert -x '"\"" : "readline-brackets \"\""'
bind -m vi-insert -x $'"\047" : "readline-brackets \\\047\\\047"' # SINGLE QUOTE
bind -m vi-insert -x '"<" : "readline-brackets \<\>"'
bind -m vi-insert -x '"(" : "readline-brackets \(\)"'
bind -m vi-insert -x '"[" : "readline-brackets []"'
bind -m vi-insert -x '"{" : "readline-brackets {}"'

Remove -m vi-insert if you use emacs mode, not vi.

share|improve this answer

Your Answer


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.