68 lines
2.0 KiB
Markdown
68 lines
2.0 KiB
Markdown
# PAT
|
|
|
|
## What it Does
|
|
|
|
`pat` is a command-line tool for concatenating and displaying the contents of files and directories. It:
|
|
|
|
1. Processes the specified files and directories recursively.
|
|
2. Appends content to a structured output with file paths and a delimiter for clarity.
|
|
3. Copies the resulting output to the system clipboard for convenient sharing or reuse.
|
|
|
|
Example use case:
|
|
|
|
- Aggregate and view the contents of multiple files or directories in one command.
|
|
- Automatically copy the aggregated result to the clipboard for seamless integration with other tools or platforms.
|
|
- Export your codebase to a markdown document.
|
|
- Export your codebase to a typst document.
|
|
|
|
## Dependencies
|
|
|
|
1. **Golang** (only to install / build):
|
|
- The application requires the Go programming language (`>= 1.18`) to compile and run.
|
|
- Dependency: `golang.design/x/clipboard` for clipboard interaction.
|
|
2. **External Tools**:
|
|
- On Wayland-based systems, `wl-copy` must be installed for clipboard functionality.
|
|
|
|
## Installation
|
|
|
|
Install pat:
|
|
|
|
```sh
|
|
git clone --depth 1 https://git.schreifuchs.ch/schreifuchs/pat.git
|
|
cd pat
|
|
go build -o=pat cmd/main.go
|
|
mv pat $GOPATH/bin/
|
|
```
|
|
|
|
In one go:
|
|
|
|
```sh
|
|
git clone --depth 1 https://git.schreifuchs.ch/schreifuchs/pat.git && cd pat && go build -o=pat cmd/main.go && mv pat $GOPATH/bin/
|
|
```
|
|
|
|
The binary will be placed in your $GOPATH/bin directory. Ensure $GOPATH/bin is in your system's PATH to run it directly.
|
|
|
|
## Example Usage
|
|
|
|
### Concatenate files and directories:
|
|
|
|
```bash
|
|
pat file1.txt folder/
|
|
```
|
|
|
|
Output is printed to the terminal and copied to the clipboard, allowing you to paste it elsewhere.
|
|
|
|
### Create printed
|
|
|
|
```sh
|
|
|
|
pat -t -i .gitignore . | typst compile /dev/stdin pat.pdf
|
|
```
|
|
|
|
---
|
|
|
|
#### Notes
|
|
|
|
- The tool uses `---------------------------------------------------------------------------` as a delimiter to separate file contents for readability.
|
|
- If clipboard functionality fails (e.g., unsupported environment), the application will still display the result in the terminal.
|