https://github.com/sivchari/trash-cli-go
A Go reimplementation of trash-cli that follows the FreeDesktop.org trash standard.
https://github.com/sivchari/trash-cli-go
trash-cli trashcan
Last synced: 6 months ago
JSON representation
A Go reimplementation of trash-cli that follows the FreeDesktop.org trash standard.
- Host: GitHub
- URL: https://github.com/sivchari/trash-cli-go
- Owner: sivchari
- License: mit
- Created: 2025-07-04T08:20:06.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-07-04T08:43:08.000Z (9 months ago)
- Last Synced: 2025-07-25T14:11:35.729Z (8 months ago)
- Topics: trash-cli, trashcan
- Language: Go
- Homepage:
- Size: 3.35 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# trash-cli-go
[](https://github.com/sivchari/trash-cli-go/actions/workflows/test.yml)
[](https://github.com/sivchari/trash-cli-go/actions/workflows/release.yml)
A Go reimplementation of [trash-cli](https://github.com/andreafrancia/trash-cli) that follows the FreeDesktop.org trash standard.
## Features
- **trash put** - Move files and directories to trash
- **trash list** - List trashed files
- **trash restore** - Restore files from trash (interactive UI)
- **trash empty** - Empty the trash (with optional age filter)
- **trash rm** - Remove specific files from trash (pattern matching)
- **trash version** - Show version information
## Installation
### Download prebuilt binaries
Download the latest release from [GitHub Releases](https://github.com/sivchari/trash-cli-go/releases).
### Using Go
```bash
go install github.com/sivchari/trash-cli-go@latest
```
### Build from source
```bash
git clone https://github.com/sivchari/trash-cli-go
cd trash-cli-go
go build -o trash
```
## Usage
### Basic Operations
```bash
# Move files to trash
./trash put file.txt directory/
# List trashed files
./trash list
# Restore files (interactive selection)
./trash restore
# Empty trash completely
./trash empty
# Remove files older than 30 days
./trash empty 30
# Remove specific files from trash
./trash rm "*.txt"
./trash rm "old_file"
# Show version
./trash version
# Get help
./trash --help
./trash [command] --help
```
### Advanced Features
- **Interactive restore** - User-friendly TUI for selecting files to restore
- **Pattern matching** - Use wildcards with `trash rm` command
- **Age-based cleanup** - Remove old files with `trash empty `
- **FreeDesktop.org compliance** - Compatible with Linux desktop environments
- **Cross-platform** - Works on Linux, macOS, and Windows
## Trash Location
Files are stored in `~/.local/share/Trash/` following the FreeDesktop.org standard, making it compatible with desktop environments like GNOME, KDE, and XFCE.
## Performance Comparison
Benchmark results comparing trash-cli-go with the original Python implementation:
| Operation | Original (Python) | Go Implementation | Improvement |
|-----------|------------------|-------------------|-------------|
| **Single file trash** | 0.488s | 0.305s | **37% faster** |
| **100 files trash** | 0.130s | 0.068s | **48% faster** |
| **List trash contents** | 0.377s | 0.031s | **92% faster** |
| **Startup time** | 0.041s | 0.004s | **90% faster** |
| **Memory usage (10MB file)** | 14.2MB | 5.2MB | **63% less** |
### Key Advantages
- **Lightning-fast startup** - No Python interpreter overhead
- **Efficient file operations** - Native system calls
- **Low memory footprint** - Ideal for resource-constrained environments
- **Better performance at scale** - Handles large numbers of files efficiently
## Compatibility
This implementation aims to be compatible with the original Python trash-cli, supporting the same command structure and .trashinfo file format.
## Development
### Prerequisites
- Go 1.24.4 or later
- make (optional, for using Makefile)
### Building
```bash
# Using make
make build
# Or directly with go
go build -o trash
```
### Testing
```bash
# Run tests
make test
# Generate coverage report
make coverage
```
### Running Benchmarks
```bash
make benchmark
```
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.