mkdir + cd in one command — create a directory and jump right into it.
See usage »
Report a Bug
·
Request a Feature
$ mkcd projects/rust/new-tool
# → creates ~/projects/rust/new-tool and cd's into it
Tired of typing mkdir -p foo/bar && cd foo/bar? mkcd collapses that into a single command. It supports nested paths, absolute paths, and bash / zsh / fish.
Highlights:
- Creates nested directories in one shot (
mkdir -pequivalent) - Automatically
cds into the created directory - Works with both absolute and relative paths
- Can
cdinto directories that already exist - Supports permission flags (
-m) - Integrates with zoxide automatically
| Crate | Purpose |
|---|---|
| clap | CLI argument parsing |
| anyhow | Error handling |
A Rust toolchain is required.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shcargo install --git https://github.com/ToB213/mkcdAdd one line to your shell's config file.
bash (~/.bashrc):
eval "$(mkcd-bin --init bash)"zsh (~/.zshrc):
eval "$(mkcd-bin --init zsh)"fish (~/.config/fish/config.fish):
mkcd-bin --init fish | sourceReload your shell and mkcd is ready to use.
# Create a nested directory and cd into it
mkcd foo/bar/baz
# Works with absolute paths too
mkcd /tmp/work/session
# cd into an existing directory
mkcd path/that/already/exists
# Create with specific permissions
mkcd -m 700 secret/dir| Option | Description |
|---|---|
-p, --parents |
Create parent directories as needed (enabled by default) |
-m, --mode <MODE> |
Set permissions in octal (e.g. 700) |
--init <SHELL> |
Print the shell integration function (bash / zsh / fish) |
cd is a shell builtin — a child process cannot change the working directory of its parent shell. mkcd works around this with a two-layer design:
mkcd foo/bar
└─ shell function mkcd()
└─ mkcd-bin foo/bar → creates the directory, prints absolute path to stdout
└─ cd /abs/path/foo/bar
The binary (mkcd-bin) is responsible only for creating the directory and printing the absolute path. The shell function receives that path and calls cd.
- Publish to crates.io
- Windows support
- Snapshot tests for
--initoutput - Expand integration test coverage
Open an issue to report bugs or suggest features.
Contributions are welcome!
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for details.
Project Link: https://github.com/ToB213/mkcd