DEV Community

Cover image for One Step Make and Change into a Directory
Meagan Waller
Meagan Waller

Posted on • Originally published at meaganwaller.com

One Step Make and Change into a Directory

I've taken a lot of time to personalize my dotfiles. There are a couple of functions I wanted to share.

Make a Directory and Change Into It

My workflow often looked like this:

mkdir some-directory
cd some-directory
Enter fullscreen mode Exit fullscreen mode

I wanted to put that workflow all into one command.

function mcd() {
  mkdir -p "$1" && cd "$1";
}
Enter fullscreen mode Exit fullscreen mode

Now I can type

mcd some-directory
Enter fullscreen mode Exit fullscreen mode

Add this function to your set up

To start using the mcd function, copy and paste the function above into your ~/.bashrc file (or ~/.zshrc file if you're using zsh), and run source ~/.bashrc (or source ~/.zshrc) to start using it.

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay