Pragmatism in today's world

Jumping to the end of bash's history

I use bash’s history all the time, via ctrl+r and also with the up and down keys; it’s wonderful.

Sometimes, I want to get back to the end of my history and I recently discovered that there’s a shortcut for this: meta+>. It doesn’t matter where you are in your history, pressing meta+> jumps you to the end and you have a blank prompt again.

I use iTerm2 on my Mac and have my right hand option key set to meta. This is done in Settings→Profiles→Keys, setting “Right Option (C) key:” to “Esc+”.

However, to press meta+>, I need to do right-option+shift+. which isn’t as easy as right-option+., so let’s rebind!

To rebind, I looked up the bash command for this functionality (`end-of-history`), and then added this to my .bashrc:

bind '"\e.": end-of-history'

All done. Now I just press right-option+. and I’m back at the end of history as if I’d never navigated it.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *