Posted in bash

Make and Change into Directory

Several times a day I have to create a directory and have immediately change into this directory. After a while I found it rather annoying to type every time

$ mkdir new_directory
$ cd new_directory

So I created a shell function to reduce the typing:

mcd ()
{
    mkdir -p "$@" && cd "$@"
}

Now I have to type only

$ mcd new_directory

and magically I’m in the newly created directory.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s