Skip to content

fuyalasmit/mkfile-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkfile

License: MIT Shell

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.

✨ Features

  • 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

🚀 Quick Install

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

📖 Usage

mkfile <path/to/file>
mkfile --help      # Show help
mkfile --version   # Show version

Examples

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

Bash Completion

Start typing a path and press Tab to autocomplete directories:

mkfile src/co<Tab>
# Autocompletes to: mkfile src/components/

🛡️ Safety Features

  • 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

💾 Manual Installation

If you prefer not to use the curl installer:

  1. Clone the repository:
git clone https://github.com/fuyalasmit/mkfile-cli.git
cd mkfile-cli
  1. Run the install script:
bash install.sh

🗑️ Uninstallation

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)

🔧 How It Works

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.

🖥️ Compatibility

  • Linux: ✅ All major distributions
  • macOS: ✅ All recent versions
  • WSL: ✅ WSL 1 and WSL 2
  • Shell: Bash 4.0+ (also works with Zsh)

📄 License

MIT - feel free to use this however you want!

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

🙏 Support

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

About

mkdir -p + touch at once

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages