Search

Jump to project's directory using simple bash function

  • Share this:
Jump to project's directory using simple bash function

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.

Tags:
Usama Muneer

Usama Muneer

A web enthusiastic, self-motivated & detail-oriented professional Full-Stack Web Developer from Karachi, Pakistan with experience in developing applications using JavaScript, WordPress & Laravel specifically. Loves to write on different web technologies with an equally useful skill to make some sense out of it.