bash

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 ()
{
  old="bob"
  history |sed -e 's/^ *[0-9]* //' | grep $1 |sort | while read line; do
    if [ "$line" != "$old" ]; then
      echo $line
    fi 
    old=$line
  done
  }

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

Syndicate content