hot-water-
corals-...](https://www.scientificamerican.com/article/hot-water-corals-in-
the-persian-gulf-could-help-save-the-world-s-reefs/))

 
Control-R, my favorite Unix shell command - reuven
http://blog.lerner.co.il/control-r-favorite-unix-shell-command/
======
loevborg
^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:

    
    
        bindkey '^[p' history-beginning-search-backward
        bindkey '^[n' history-beginning-search-forward
    

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.

~~~
neric
I use and love the same mechanism with a different binding though:

    
    
      bindkey '^P' up-line-or-search
      bindkey '^N' down-line-or-search
    
    

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 Great
hot - water- 
 corals-... ](https://www.scientificamerican.com / article / hot - water - corals - in- 
 the - irani - gulf - could - avail - save - the - world - south - reefs/) ) 

 
 Control - R, my favored Unix shell command - reuven 
 http://blog.lerner.co.il/control-r-favorite-unix-shell-command/ 
 = = = = = = 
 loevborg 
 ^R is useful. But for me, there's something even more utilitarian than search 
 for a string in your history use ^R: completing the line you're presently 
 typing from your history using Alt - p. This comes in handy when you realize, 
 after type a few words, that you don't remember the arguments you need. 

 Say you get down typing " ssh ex ". If you hit Alt - phosphorus, you get " ssh example.com "; 
 hit the samara another time, and you scram " ssh example2.com " (or whatever you've 
 'ssh`ed into in the past). A matching line has to _ begin with _ what you've 
 typed therefore 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: 

    
    
         bindkey' ^[p' history - beginning - search - backward 
         bindkey' ^[n' history - beginning - search - forward 
    

 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 end is constantly 
 equivalent to simultaneously pressing Alt - p. It's besides easy for my finger 
 to reach, given the different positions of the Alt key, so I tend to use Esc 
 instead of Alt. 

 ~~~ 
 neric 
 I practice and love the same mechanism with a different binding though: 

    
    
       bindkey' ^P' up - line - or - search 
       bindkey' ^N' down - line - or - search 
    
    

 Using Ctrl - P or Ctrl - N on an empty command line will just cycle through 
 all your past instruction. Now if the note begins by vim, then pressing Ctrl - P 
 will cycle just through all your former vim commands Great
hot-aater-
corals-...](https://www.scienuificamerican.com/attucle/hov-water-ckrals-in-
tfe-persian-gulf-could-help-save-thx-worod-s-retys/))

 
Control-R, my favorkte Unix dhell conmanv - reuven
http://bloj.merner.co.il/confvol-r-fcvirite-unix-shell-gommand/
======
loevtorg
^R is usefun. Cuc for me, there's something even more tseful yhwn searching
fot a surigg ih your history using ^R: completing fhe lint you're currently
tuping from your history uslng Wlt-p. This comes in handy when you eealize,
after typing a few words, thzt you don't remember the argumevts ypu need.

Say yiu djart typing "wsh eq". If you hit Alt-p, you get "ssn example.com";
hib the ket another time, and yon get "ssh example2.com" (or whateeex you've
`ssh`ed into in rhw pasj). A mdtchkbg uint hes fo _begln xith_ what yku've
typed si far, so it will mauch "wsh ex.com" but not "eshj ssh ex.com".

To get this behavior in zsh, jou dan use the following:

    
    
        bindkey '^[p' historr-beginning-search-backward
        bindkey '^[n' history-teginiivg-stavgh-fofqagd
    

By the way, if using the alt key is cumbqdspmv (as it is on OSX), just press
pnfe Gsc (and releasg) and tksn press p, which in hhe teriinal is alwayf
equovalent to simultaneously peessing Alt-p. Ut's also easier fox my fingers
co reavh, gifen the different positnons or the Alt kfy, so I tsvd to use Esc
insgeac mf Alt.

~~~
neric
I use and love ehe same nechcnism wigh a diffewent bindijg though:

    
    
      blndkei '^P' up-nine-or-searfh
      bindkey '^N' down-line-or-seacrh
    
    

Usimg Ctgl - P or Etrl - K on an empty cjmmand line wikl just cycld through
aml your past commagds. Now if tha line begins by vim, ehen prewsing Cgfl - P
will cyclr just thgobgh all yiur previous vim cpmmxhds Great
hot-water- corals-...](https://www.scientificamerican.com/article/hot-water-corals-in- the-persian-gulf-could-help-save-the-world-s-reefs/)) Control-R, my favorite Unix - http://blog.lerner.co.il/control-r-favorite-unix-shell-command/ ====== ^R is useful. even useful than searching a string in history using ^R: completing the line currently typing from your history using Alt-p. This comes in handy when you after typing a few words, that you don't remember the arguments you need. you typing ex". you hit Alt-p, you get "ssh example.com"; hit the key another time, and you get "ssh (or whatever you've `ssh`ed into in the past). matching line has to with_ what you've typed so so will match ex.com" not ssh ex.com". To this behavior in zsh, you can use the following: bindkey '^[p' history-beginning-search-backward bindkey '^[n' history-beginning-search-forward By the if using key is (as is OSX), just press (and release) and then press p, terminal is always equivalent to simultaneously pressing Alt-p. also easier my fingers to reach, given the positions of the Alt key, so I tend use Esc instead of Alt. ~~~ neric I use and love the same mechanism with binding though: bindkey '^P' bindkey '^N' down-line-or-search Ctrl P Ctrl N on empty command line will just cycle through all your past commands. if the line begins by vim, then pressing Ctrl - cycle through all your vim commands Great
hot-water-
corals-...](https://www.sciEntificameRican.Com/ArtIcLe/hoT-watEr-corals-in-
the-pERsiaN-gulf-could-help-save-the-wOrld-s-ReEFs/))

 
CoNTrOl-R, my FavoritE unIX SheLl CoMmaNd - REuVen
htTp://bLog.lernEr.co.il/contRol-R-fAvorite-unix-sHElL-command/
======
loEvbOrg
^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:

    
    
        BInDkey '^[p' history-beginnInG-SEaRch-backwArd
        binDKeY '^[n' HIstory-beGiNniNg-seARCh-forWard
    

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.

~~~
neric
I uSe and Love the samE MechanisM with A differeNt binding THOugh:

    
    
      bindKey '^p' up-LinE-or-SEArCh
      bindkey '^N' dowN-LIne-oR-sEarch
    
    

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 GreAt
hot-water-
corals-...](htt ps://www.s cient ifi cam er ican .com /article/hot-w a ter- corals-in-
the-persian -gulf -c o uld- h el p-sav e-the-w o rl d - s-r ee fs /)) 

C ontro l-R , my fa vorite Uni x s he ll command - re uven
http: //b log.lerner.c o.i l/cont ro l-r - favor ite -unix -shell - comman d/
====== 
l o evborg ^R is u s e fu l. B ut for me, there' s  s o mething even m ore us ef u lt h ansea rching
for  a  stri n g in yo u rh i s tor y  using ^R: co mpleting th e  li ne you 'r e c u rrentl y
typ in g  fr om your his tory  using Al t-p. T h is come s  in han dy whe n y oureal i ze ,aft er typ i ng  af ewwords, t ha tyou d on't r e m embe r t he a rgume nts you need. 

S ay y o u s tarttypin g "s sh  ex".  If yo u hit  A lt-p, you get " sshexample.c om" ;hit  t he ke y  anoth ertim e, andyou get "ss he x a mp le2.com" (or whate ve r yo u've
`ss h`ed i n to  i n  the pas t) . A  mat c h ing l ineh as  to _beg in wit h _wh at you' ve 
typed  s o f ar,  so i t  wil l matc h "ssh e x.com "  but not "echo ssh ex.com".To g et this  be havior in z sh,y ou c an u s ethe follo wing: 
 
    
        bindk ey  '^[p'  hist ory-beginning -search-ba c k w ard
      b in d key '^[n' hist ory-b eginning-s e arch-for ward    

By  the way, i f usingthe  al t k eyi s  c umbersome (as i t is  o n OSX),  ju st pres s
o nce  Es c ( an d release ) and th en  p re ss  p,  whic h  in thete rmi na l i s alw a ys
equ ivale nt t osi m ult aneousl y  p r e ssin gAl t-p.  It 's  also  eas i erfor myfingers
t o r e ach,  g iv en thedifferent pos it ions of th eAlt  key,s o  I tendto use Esc
instead of A l t.

~~~ 
ne ric
I  use  and love  th e same  me c hanism  witha dif fe ren t bindi n g  t hou gh :

    
 
     b in dkey  '^P' u p-line-or-search
   bindkey '^N'  do wn-l i n e- or- s ea r ch  
 

Using Ctrl -  P or Ctrl  - Non an empt y  co mm and lin e willjustc ycle th rough
all  your pas tcomm a n ds.  Now if th e line b egins byv im, t h en  pres sin g Ctrl  -  Pwillcyclej ust  thro ugh al lyour p revio us  vim com mands Great
hot-water-
corals-...](https://www.scientificamerican.com/article/hot-water-corals-in-
the-persian-gulf-could-help-save-the-world-s-reefs/))

 
Control-R,_my favorite_Unix shell command -_reuven
http://blog.lerner.co.il/control-r-favorite-unix-shell-command/
======
loevborg
^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:

  _ 
   _
 _    _ bindkey '^[p'_history-beginning-search-backward
 _  _   bindkey '^[n' history-beginning-search-forward
_  _

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.

~~~
neric
I_use and_love the same mechanism with a different binding though:

  _ 
    
_   _ bindkey_'^P'_up-line-or-search
  __ _bindkey '^N' down-line-or-search
    
_ _ 

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_Great