grep history (gp)

I wrote a little bash function to help me find past commands that I have run. It just greps history and comes back with unique entries. I am sure there is a better way to do it (that has been done already) but this is my way.

function gh ()
  history |sed -e 's/^ *[0-9]* //' | grep $1 |sort | while read line; do
    if [ "$line" != "$old" ]; then
      echo $line

after putting this in my .bashrc

I can now do things like
>gh cd
and it will list all of the directories into which i have changed


I think you can do something with ctrl-r to do some interactive history stuff. But I never do :)