mkdir and cd at the Same Time

Fact: I’m lazy as hell. mkdir x && cd x for whatever reason just seems too long to create a directory and cd into it at the same time.

To engage in my laziness, append the following to your ~/.bashrc

function mkcd(){
    mkdir -p $1 && cd $1
}

Now execute the command source ~/.bashrc so your session takes the edited file into account.

Now simply executing

mkcd testFile

will create the testFile directory and make that your working directory.

Horray for lazy!


Related Posts:

About the Author:

Joseph is the lead developer of Vert Studios, a web design company located in Tyler, Tx. Follow him on Twitter! @Joe_Query.

  1. Dude, thank you. I like to think of it as “increasing workflow efficiency” when using these kinds of tips. Great tip.

Add to the conversation: