cdh bash command to change directory to a path from your history
Door FlorisVedder op do, 08/03/2017 - 21:33

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
- go to your terminal / commandline
echo $PATH
- go to one of the directories that's in your $PATH
wget https://raw.githubusercontent.com/FlorisVedder/cdhistory/master/cdhistory.sh
- open your ~/.bash_profile in an editor
- Add this function to the bash profile:
cdh () { source cdhistory.sh ; }
- save your ~/.bash_profile
source ~/.bash_profile
- Run the command:
cdh
- Enter the number that represent your path of choice
- 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.