Thanks to visit codestin.com
Credit goes to lib.rs

#notifications #touch #mkfile #gntp

app mkfiler

Cross-platform file creation utility with GNTP/Growl integration

2 stable releases

Uses new Rust 2024

1.0.3 Dec 9, 2025
1.0.1 Dec 1, 2025

#1 in #touch

MIT license

59KB
310 lines

mkfile - Advanced File Creator

A powerful command-line utility for creating blank files with support for brace expansion, automatic directory creation, desktop notifications, and clipboard integration.

Features

  • Brace Expansion: Create multiple files with a single command
  • 📁 Auto Directory Creation: Automatically creates parent directories if they don't exist
  • 📋 Clipboard Integration: Copies absolute file paths to clipboard
  • 🔔 Desktop Notifications: Optional Growl notification support
  • 🖥️ Cross-Platform: Works on Windows, Linux, and macOS
  • 🎯 Smart Parsing: Handles complex patterns with spaces and multiple items

Installation

cargo install mkfiler

Usage

Basic Syntax

mkfile [OPTIONS] FILE [FILE ...]

Examples

Create Single File

mkfile test.txt

Create Multiple Files

mkfile file1.txt file2.rs file3.js

Create Files with Directory Structure

mkfile src/main.rs tests/test_main.rs
# Creates: src/ and tests/ directories automatically

Brace Expansion - Simple

mkfile test/{a,b,c}.txt
# Creates: test/a.txt, test/b.txt, test/c.txt

Brace Expansion - Directory Prefix

mkfile dotenv{core.rs,utils.rs}
# Creates: dotenv/ dotenv/core.rs, dotenv/utils.rs

Brace Expansion - With Spaces (Flexible Syntax)

mkfile src{main.rs, utils.rs config.rs}
# Creates: src/main.rs, src/utils.rs, src/config.rs
# Note: Handles both comma and space separation inside braces

Complex Project Structure

mkfile src/{main.rs,utils.rs} tests/{test_main.rs} README.md setup.rs requirements.txt

Real-World Example

mkfile mypackage/{core.rs,exceptions.rs,utils.rs} tests/{test_core.rs} setup.rs Cargo.toml README.md LICENSE requirements.txt .gitignore

Brace Expansion Syntax

Supported Formats

  1. Standard format (recommended):

    mkfile dir/{file1,file2,file3}
    
  2. Directory prefix (no slash):

    mkfile dir{file1,file2,file3}
    # Automatically adds '/' → dir/file1, dir/file2, dir/file3
    
  3. With spaces (flexible):

    mkfile dir{file1, file2, file3}
    mkfile dir{file1 file2 file3}
    # Both work! Splits by comma AND spaces
    
  4. With file extensions:

    mkfile src/{main,utils,config}.rs
    # Creates: src/main.rs, src/utils.rs, src/config.rs
    

Brace Expansion Rules

  • Items inside {} can be separated by:
    • Commas: {a,b,c}
    • Spaces: {a b c}
    • Both: {a, b, c} or {a, b c}
  • If prefix doesn't end with / or \, it's treated as a directory name
  • Empty items are skipped
  • Nested braces are not supported

Command-Line Options

--version

Show version information

mkfile --version

--debug

Enable detailed error messages and stack traces

mkfile --debug file1.txt file2.txt

--help

Show help message with examples

mkfile --help

Output

Success

✓ File created: "C:\PROJECTS\myproject\src\main.rs"
✓ File created: "C:\PROJECTS\myproject\src\utils.rs"

2/2 file(s) created successfully

With Errors

✓ File created: "valid.txt"
✗ Error creating file "invalid/path/file.txt": [Errno 13] Permission denied

1/2 file(s) created successfully

Features in Detail

Automatic Directory Creation

The script automatically creates all parent directories:

mkfile deep/nested/path/to/file.txt
# Creates: deep/ → deep/nested/ → deep/nested/path/ → deep/nested/path/to/

Clipboard Integration

After creating each file, its absolute path is automatically copied to your clipboard (requires clipboard module).

Desktop Notifications

If Growl is installed and running, you'll receive desktop notifications for each file created.

Note: The "Could not initialize Growl" warning is normal if Growl is not running. The script continues to work perfectly without it.

Troubleshooting

"Could not initialize Growl" Warning

This is normal and harmless. It means Growl notification service isn't running. The script works fine without it.

To suppress this warning, you can:

  • Install and run Growl
  • Or ignore it (doesn't affect functionality)

Permission Denied Errors

If you get permission errors:

  • Check directory permissions
  • Run with appropriate privileges
  • Use --debug flag for more details

Files Not Created in Expected Directory

Check your brace expansion syntax:

# WRONG - No directory separator
mkfile mydir{file1,file2}      # Creates: mydir/file1, mydir/file2 ✓

# If you want nested directories, use /
mkfile mydir/{subdir/file1,file2}  # Creates: mydir/subdir/file1, mydir/file2

Tips & Best Practices

  1. Use quotes for files with spaces:

    mkfile "my file.txt"
    
  2. Combine with other commands:

    mkfile src/{main,utils}.rs && code src/main.rs
    
  3. Create project templates:

    # Save as a shell script
    mkfile project/{src,tests,docs}/{__init__.rs} README.md setup.rs
    
  4. Verify with tree command:

    mkfile test/{a,b,c}.txt && tree test/
    

Version History

v2.0

  • Added smart brace expansion parsing
  • Auto directory creation
  • Support for space-separated items in braces
  • Improved error handling
  • Better cross-platform support
  • Class-based architecture

v1.0

  • Initial release
  • Basic file creation
  • Growl notifications

License

Free to use and modify.

Contributing

Feel free to submit issues and enhancement requests!


Quick Reference:

# Single file
mkfile file.txt

# Multiple files
mkfile file1 file2 file3

# With directories
mkfile src/main.rs tests/test.rs

# Brace expansion
mkfile src/{main,utils,config}.rs

# Complex structure
mkfile mypackage/{__init__,core,utils}.rs tests/{__init__,test_core}.rs README.md

Author

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi

Support me on Patreon

Dependencies

~4–15MB
~137K SLoC