gcopy
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
via Finder
, 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
Install
Via go install
go install github.com/TheDen/gcopy@latest
Brew
To install via brew
brew tap theden/gcopy
brew install gcopy
Aliasing
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
Overview
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
Copying to clipboard via STDIN
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
Passing in files to copy to the clipboard
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
Getting the absolute path of a file or folder
gcopy -p .bashrc
/Users/den/.bashrc