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 | bashThen restart your terminal or run:
source ~/.bashrc # or ~/.zshrc for zsh usersmkfile <path/to/file>
mkfile --help # Show help
mkfile --version # Show versionCreate a simple file:
mkfile file.txtCreate a file in nested directories:
mkfile src/components/Button/index.tsx
# Creates: src/ → components/ → Button/ → index.tsxCreate a deeply nested configuration file:
mkfile config/database/production/settings.ymlStart 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,
mkfilewill 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.shcurl -sSL https://raw.githubusercontent.com/fuyalasmit/mkfile-cli/main/uninstall.sh | bashOr if you have the repo cloned:
bash uninstall.shThis will:
- Remove
mkfilefrom~/.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