Manoj Rao bio photo

Manoj Rao

Your Average Common Man

Email Twitter Github

In earlier posts, I have shared my productivity tricks with Emacs and Git. In this post, I will share some of the commonly used shell tricks that have helped me be/stay productive.

Command History

Search for a previously run command

history | grep <pattern>

OR

Ctrl-R <pattern>

Repeat Last Command

Repeating the most recent command

UP arrow then ENTER

OR

!!

Repeat Last Command Starting With …

!<starting pattern>

Reopen the last file with vim that contains a long filename which you can’t remember

!v

If you want to be sure that the last command starting with v is indeed vim and not vscode (Ugh) then you can examine to make sure the last command was OK.

!v:p

Repeat the Last Command With New Arguments

ls foo
ls bar

OR

ls foo
!!:0 bar

Repeat Last Arguments With New Command

vim /tmp/foo.txt
emacs /tmp/foo.txt

OR

vim /tmp/foo.txt
^vim^emacs

Hold Result Of Command

find . -name "blahblah.txt"
# found in here/there/everywhere/blahblah.txt
rm here/there/everywhere/blahblah.txt

OR

rm `find . -name "blahblah.txt"`

# same as

rm $(find . -name "blahblah.txt")

My Podcast!

If you like topics such as this then please consider subscribing to my podcast. I talk to some of the stalwarts in tech and ask them what their favorite productivity hacks are:

Available on iTunes Podcast

Visit Void Star Podcast’s page on iTunes Podcast Portal. Please Click ‘Subscribe’, leave a comment.

Get it iTunes

Available on Google Play Music

Visit Void Star Podcast’s page on Google Play Music. Please Click ‘Subscribe’ and leave a comment.

Listen on Google Play Music
Available on Stitcher

Visit Void Star Podcast’s page on Sticher. Please Click ‘Subscribe’ and leave a comment.

Listen to Stitcher

Your app not listed here? Not an issue..

You should be able to search for ‘VoidStar Podcast’ on your favorite app. Most apps use one of the above sources for listing podcasts. This was tested on Podcast Addict (where you can also specify the search engine) and RatPoison on Android.