Normally you cd into your html or code directory and then cd into your project's directory. In this article I'll explain how a simple bash function can save up your precious time for cd-ing into directories over and over again.
Let's straight dive in and open up our bash file. In my case, it's bash_profile
Open up your terminal & follow along.
$ subl ~/.bash_profile
The function
function cdhtdocs { cd "C:/xampp/htdocs/$1" }
Add into the context
$ source ~/.bash_profile
The use-case
Now lets assume you want to switch to your project's directory that's located in "C:/xampp/htdocs/foobar".
You'll have to simply type:
$ cdhtdocs foobar
Easy? Isn't it?
Final Words
Bash functions are always helpful if you know the right use-case. If you're a terminal rookie, then this little trick might come in handy.
If you've any questions, leave us a comment below or ask us on Twitter.