^R is useful. But for me, there's something even more useful than searching for a string in your history using ^R: completing the line you're currently typing from your history using Alt-p. This comes in handy when you realize, after typing a few words, that you don't remember the arguments you need.
Say you start typing "ssh ex". If you hit Alt-p, you get "ssh example.com"; hit the key another time, and you get "ssh example2.com" (or whatever you've `ssh`ed into in the past). A matching line has to begin with what you've typed so far, so it will match "ssh ex.com" but not "echo ssh ex.com".
To get this behavior in zsh, you can use the following:
By the way, if using the alt key is cumbersome (as it is on OSX), just press once Esc (and release) and then press p, which in the terminal is always equivalent to simultaneously pressing Alt-p. It's also easier for my fingers to reach, given the different positions of the Alt key, so I tend to use Esc instead of Alt.
Using Ctrl - P or Ctrl - N on an empty command line will just cycle through all your past commands.
Now if the line begins by vim, then pressing Ctrl - P will cycle just through all your previous vim commands
Greatness!
I have history-search-backward and its reverse mapped to page up and page down. A rare few Linux distributions enable them by default, but the rest frequently have a commented example in /etc/inputrc that can be copied to your ~/.inputrc (note that programs using editline instead of readline will need additional configuration).
Me too. And not entering anything gives normal arrow up, so there's no loss.
BTW: ^r is a little more powerful: it is /string/ while this one is /^string/
BTW ^r annoyance: you can't type and then hit ^r. You have to hit ^r first. Seems easy to fix...
BTW tip: if you like readline features, consider rlwrap: it wraps its argument (which is your command) in readline. e.g. rlwrap python. Especially nice to wrap your own interactive cmdline tool.
Say you start typing "ssh ex". If you hit Alt-p, you get "ssh example.com"; hit the key another time, and you get "ssh example2.com" (or whatever you've `ssh`ed into in the past). A matching line has to begin with what you've typed so far, so it will match "ssh ex.com" but not "echo ssh ex.com".
To get this behavior in zsh, you can use the following:
By the way, if using the alt key is cumbersome (as it is on OSX), just press once Esc (and release) and then press p, which in the terminal is always equivalent to simultaneously pressing Alt-p. It's also easier for my fingers to reach, given the different positions of the Alt key, so I tend to use Esc instead of Alt.