Create nested directories and files in one command
A minimal CLI tool that makes it easy to create files with their parent directories automatically. No more mkdir -p
followed by touch
– just mkfile
.
- Simple: One command to create directories and files
- Safe: Won't overwrite existing files
- Fast: Lightweight bash script with zero dependencies
- Smart: Bash autocompletion for file paths
- Cross-platform: Works on Linux, macOS, and WSL
curl -sSL https://raw.githubusercontent.com/fuyalasmit/mkfile-cli/main/install.sh | bash
Then restart your terminal or run:
source ~/.bashrc # or ~/.zshrc for zsh users
mkfile <path/to/file>
mkfile --help # Show help
mkfile --version # Show version
Create a simple file:
mkfile file.txt
Create a file in nested directories:
mkfile src/components/Button/index.tsx
# Creates: src/ → components/ → Button/ → index.tsx
Create a deeply nested configuration file:
mkfile config/database/production/settings.yml
Start typing a path and press Tab
to autocomplete directories:
mkfile src/co<Tab>
# Autocompletes to: mkfile src/components/
- No overwriting: If a file already exists,
mkfile
will show an error and stop - Path validation: Ensures the path is valid before creating anything
- Error handling: Clear error messages if something goes wrong
If you prefer not to use the curl installer:
- Clone the repository:
git clone https://github.com/fuyalasmit/mkfile-cli.git
cd mkfile-cli
- Run the install script:
bash install.sh
curl -sSL https://raw.githubusercontent.com/fuyalasmit/mkfile-cli/main/uninstall.sh | bash
Or if you have the repo cloned:
bash uninstall.sh
This will:
- Remove
mkfile
from~/.local/bin
- Remove bash completion
- Clean up your shell configuration (backup created automatically)
Under the hood, mkfile
is a simple bash function:
mkdir -p "$(dirname "$1")" && touch "$1"
That's it! But wrapped in a script with proper error handling, installation, and completion.
- Linux: ✅ All major distributions
- macOS: ✅ All recent versions
- WSL: ✅ WSL 1 and WSL 2
- Shell: Bash 4.0+ (also works with Zsh)
MIT - feel free to use this however you want!
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
If you find this tool useful, please consider:
- ⭐ Starring the repository
- 🐛 Reporting bugs
- 💡 Suggesting new features
- 🔀 Contributing via pull requests
Author: fuyalasmit
Repository: github.com/fuyalasmit/mkfile-cli