Thursday, March 28, 2013

OSX: terminal history tools: ctrl-r

Ah, more pleasure from the stock OSX terminal...

Obviously, there's the old "up/down arrow" to get back to commands you've previously entered so you can rerun or modify and rerun them.

Sometimes the command you want is far back though. For a long time I knew about "!"... so typing
    !cp
would repeat the last cp command.

And that's good, but sometimes it feels like Google's old "I'm Feeling Lucky" button... I may have used "cp" since the time I was thinking of.

My friend Jonathan pointed out "ctrl-r" in Terminal... press it and it starts an interactive search-- in this case I could type "cp" and it would show me the last copy, then I could accept it by hitting return, or hit ctrl-R again to find the one before that, etc.

He also directed me to this lifehacker page that suggests bumping up the size of your command history.

No comments:

Post a Comment