Quickly searching bashs history

For me one of BASHs kill features is the possibility to quickly search the history of commands you entered: press CTRL + R and begin typing the command you’re looking for.

Assume you want to (re-)install a maven project on glassfish. You know you did it a dew hours/days ago but don’t remember the exact syntax. Here’s the solution:
Your command line looks like this:

Last login: Wed Feb 19 12:56:08 on ttys004
Volkers-MacBook-Pro:~ volker$>

Then press CTRL+R – the command prompt changes:

Last login: Wed Feb 19 12:56:08 on ttys004
Volkers-MacBook-Pro:~ volker$>
Volkers-MacBook-Pro:~ volker$>
(reverse-i-search)`':

Now you can start typing away:

Volkers-MacBook-Pro:~ volker$>
(reverse-i-search)`redeplo': mvn -Pglassfish-remote clean package glassfish:redeploy

Now you’re shown the last command entered that matches the substring you entered.
To browse other matches simply hit CTRL+R again.

Advertisements

About javavolker71

when i do not write posts on this blog, don't work on or try to break my code i'm spending a reasonable amount of time
This entry was posted in Apple, IT, Linux, OS X, shell, Unix and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s