dircat

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 8 Imported by: 0

README

dircat

dircat is a lightweight command-line tool that recursively concatenates files from a directory into a single text output, while also providing an option to generate a file tree. By default, it outputs the result to the console, but users can redirect the output to a file if needed.

Features

  • Recursively generates a file tree of a given directory.
  • Outputs the contents of all non-binary files in a directory.
  • Skips hidden files, .pyc files, __pycache__ directories, and binary files.
  • Supports clean, simple console output by default.
  • Optional file output via a command-line flag.
  • Modular with subcommands for tree generation and file content aggregation.

Installation

Install via Binary
  1. Build the Go binary:

    go build -o dircat
    
  2. Move the binary to your desired location:

    mv dircat ~/xpritools/
    
  3. Add ~/xpritools to your $PATH: For Zsh (default shell on macOS since Catalina):

    echo 'export PATH="$HOME/xpritools:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    

    For Bash:

    echo 'export PATH="$HOME/xpritools:$PATH"' >> ~/.bash_profile
    source ~/.bash_profile
    
  4. Now you can run dircat from anywhere in your terminal!

Install via Homebrew (coming soon)

You will soon be able to install dircat via Homebrew with:

brew tap xprilion/tools
brew install dircat

Usage

Basic Commands
  • File Tree: Display a tree of the directory structure.

    dircat tree /path/to/folder
    
  • File Contents: Display the contents of all non-binary files in the directory.

    dircat content /path/to/folder
    
  • All: Display both the file tree and contents of the files.

    dircat all /path/to/folder
    
Redirecting Output to a File

To save the output to a file, simply redirect the output using >>:

dircat all /path/to/folder >> output.txt

Or use the -o flag to specify an output file:

dircat all /path/to/folder -o output.txt

Skipped Files

The following files are skipped by default:

  • Binary files (those that cannot be displayed as text)
  • Hidden files (starting with ., like .git)
  • .pyc files and __pycache__ directories

Contributing

Contributions are welcome! Feel free to fork the repository and submit a pull request. Please ensure your code follows the existing style and passes all tests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL