gcopy
(global copy) is a command line tool that copies data to your clipboard on MacOS.
It does what pbcopy
does but with some extra features:
- Works with images, so copied images can be pasted in other applications
- Accepts arbitrary
STDIN
via a pipe - If a filename is passed as an argument it'll copy the data as though you hit
CMD+C
viaFinder
, allowing pasting of files (PDFs, archive files, videos etc.) to other programs - Has an optional flag to copy the absolute pathname of a file or folder to the clipboard
- Written in Go, deployed as a multi-arch static binary
- Works as a drop-in replacement for
pbcopy
since it extends its features
go install github.com/TheDen/gcopy@latest
To install via brew
brew tap theden/gcopy
brew install gcopy
gcopy
can be used as a drop-in replacement for pbcopy
. To do this, add the alias
into your .bashrc
or similar
alias pbcopy='gcopy'
usage: gcopy [file] [STDIN] [-h|--help] [-v|--version] [-p|--path]
gcopy: copy content to the clipboard
Arguments:
-h --help Print help information
-v --version Current version
-p --path Copy (and show) the absolute pathname of a file or folder to
the clipboard
Works with text or arbitrary data
cat main.go | gcopy
# or
gcopy < main.go
Images can also be copied via pipes, and then pasted as images to GUI applications
cat image.png | gcopy
# or
gcopy < image.png
gcopy main.go
Similarly for images
gcopy image.png
Or any other type of file
gcopy backups.zip
Copying via this method will allow you to paste non-text data in other applications
gcopy -p .bashrc
/Users/den/.bashrc