The Art of “CD Create”: Supercharging Your Terminal Workflow
If you spend any significant amount of time in a command-line interface, you already know the familiar rhythm of muscle memory: mkdir new-project, followed immediately by cd new-project.
While typing those extra few characters might only take a second, the philosophy of developer efficiency dictates that repetitive friction is meant to be eliminated. Enter “cd create”—the ubiquitous concept and custom workflow of combining directory creation and navigation into a single, seamless motion.
The Minor Friction That Adds Up
Out of the box, standard shells like Bash or Zsh treat directory creation and navigation as completely separate concerns.
mkdiris a binary executable that spins up a folder on your file system.cdis a shell builtin command designed exclusively to change your current working directory.
Because they operate independently, you are forced to tell the computer twice to do what is conceptually a single action: “Make a home for this new thing, and take me inside it.” Multiply that across dozens of projects, branches, and temporary directories every day, and that redundant keystroke pattern starts to drag down your flow state.
How to Build Your Own “CD Create” Shortcut
Because operating systems don’t natively ship with a built-in cd-create command, developers have perfected a lightweight, elegant solution: a custom shell function typically named mkcd (or cdo, depending on your preference).
Setting up your own takes less than a minute.
1. Open Your Shell Configuration File
Depending on your environment, open your configuration file (~/.bashrc, ~/.zshrc, or your shell’s equivalent) in your favorite text editor:
nano ~/.zshrc
2. Add the Function Snippet
Paste the following robust snippet anywhere in the file:
mkcd() {
mkdir -p -- "$1" && cd -P -- "$1"
}
Why this snippet works brilliantly:
mkdir -p: The-pflag ensures that if you specify a deeply nested path (likeprojects/2026/client-alpha), it will safely create all intermediate parent directories along the way without throwing an error if they already exist.--: This signals the end of command-line options, protecting your script if your directory name happens to start with a hyphen (
Leave a Reply