Create a gist now

Instantly share code, notes, and snippets.

@caseywatts /.inputrc
Last active Jun 15, 2017

What would you like to do?
BEST THING EVER
# for bash
### Search History (autocomplete style~)
# Press up-arrow for previous matching command
"\e[A":history-search-backward
# Press down-arrow for next matching command
"\e[B":history-search-forward
# for zsh
### Search History (autocomplete style~)
# Press up-arrow for previous matching command
bindkey "^[[A" history-search-backward
# Press down-arrow for next matching command
bindkey "^[[B" history-search-forward

Short link to this: caseywatts.com/bashautocomplete

Other gists & tricks: http://caseywatts.com/gists-and-tricks

Bash/zsh Autocomplete

So you typed something into the terminal before and you wanna bring it up now? Once that code above is in your .inputrc (for bash) or your .zshrc, then try it out:

  • type the first few characters of the thing (fortunately you remember how it started)
  • press the up arrow key. the most recent command that starts with those letters shows up
  • up again to cycle back further
  • press down to go back one :)

(there's a related thing called reverse-i-search that you can do with ctrl+r (see here) but I definitely don't like it as much b/c you can't cycle up and down, just in one direction~)

@sameetn

This comment has been minimized.

Show comment Hide comment
@sameetn

sameetn Jun 14, 2017

I think reverse search works as ctrl+r in one direction and ctrl+shift+r in the other direction

sameetn commented Jun 14, 2017

I think reverse search works as ctrl+r in one direction and ctrl+shift+r in the other direction

@caseywatts

This comment has been minimized.

Show comment Hide comment
@caseywatts

caseywatts Jun 15, 2017

@sameetn I wish something like that would work too!
I believe you that it works somewhere - but that didn't work on my mac just now :/

Owner

caseywatts commented Jun 15, 2017

@sameetn I wish something like that would work too!
I believe you that it works somewhere - but that didn't work on my mac just now :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment