GitXplorerGitXplorer
b

trash

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
7c9a187a02225237dc97edffeecb44dd7e1cafad

rename archive

bbzimmer committed 5 months ago
Verified
25cc83e67099beaba38d38d64711d333d1a1d26a

Merge pull request #2 from bzimmer/release-name

bbzimmer committed 5 months ago
Unverified
5616eee1db3f179467d3edbf1d3ecf9f45a52203

improved naming of archive

bbzimmer committed 5 months ago
Verified
3bab062b0ff95657b2e2afb98334d18097f0ef07

Merge pull request #1 from bzimmer/packaging

bbzimmer committed 5 months ago
Unverified
61e1bddf2893fb763e7fcd1adbcd28905dedbe08

upgraded build ecosystem

bbzimmer committed 5 months ago
Unverified
b7570bb8234ca3d3e125e0d294bfb8d629163cc8

improved error handling; corrected formatting

bbzimmer committed 5 months ago

README

The README file for this repository.

Trash

A simple tool for programatically trashing selected files in MacOS Finder.

Supports files passed as arguments or from standard input, either as absolute or relative paths.

Installation

Prerequisites

  • macOS 10.15 (Catalina) or later
  • Xcode and the Command Line Tools installed

From source

Clone the repository and navigate to the project directory:

git clone https://github.com/bzimmer/trash.git
cd trash

Build:

task build

Usage

trash [-0] [--] [files...]
  -0: Expect NUL (`\0`)-terminated filename strings on stdin
  --: End of options processing; all subsequent arguments are files

Either absolute and relative paths may be supplied, and may be mixed in the same invocation. Relative paths will be resolved from the current working directory.

Paths may be passed as arguments, or from standard input, but not both. If supplied via arguments whilst stdin has data available, then stdin will be ignored and the arguments will be used, and a warning will be issued. This warning is suppressed by the -- option.

Always supply the -- option when passing filename(s) via arguments from within another script/application. Not only does it silence the warning, this prevents misbehaviour when a relative path begins with a hyphen.

Examples

Trash files passed as arguments:

trash file1.txt file2.txt

Find and trash files with a PDF extension in your Documents folder and subfolders:

fd -0 -e pdf . ~/Documents | trash -0

Alternatively:

fd -e pdf . ~/Documents -X trash {}

Trash a file supplied from user input:

read -p 'file: ' FILENAME
trash -- "$FILENAME"

Credits

Shamelessly borrowed the concept and much of the code from reveal, a tool I used nearly daily. The primary changes are reformatting and the action of revealing files was changed to trashing them.