cdh bash command to change directory to a path from your history

cdh cd to a path from your bash history

Sometimes you have long paths and want to enter them the second time faster. An other time you've worked on several projects and don't know that path from a couple of projects back. Some cases where it should be great if you can just switch to a path* from your history.

I created a little script cdhistory that has this functionality for you.

Steps to setup the script so you just can run: cdh

  1. go to your terminal / commandline
  2. echo $PATH
  3. go to one of the directories that's in your $PATH
  4. wget
  5. open your ~/.bash_profile in an editor
  6. Add this function to the bash profile: cdh () { source ; }
  7. save your ~/.bash_profile
  8. source ~/.bash_profile
  9. Run the command: cdh
  10. Enter the number that represent your path of choice
  11. And you're in the selected directory

*It's only fetching absolute paths from your history. Code is made on an osx machine, not yet tested or improved for Linux.