https://github.com/nakabonne/pbgopy
Copy and paste between devices
https://github.com/nakabonne/pbgopy
cli clipboard copy-paste go golang
Last synced: about 2 months ago
JSON representation
Copy and paste between devices
- Host: GitHub
- URL: https://github.com/nakabonne/pbgopy
- Owner: nakabonne
- License: mit
- Created: 2020-11-25T12:35:10.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2026-04-29T04:04:35.000Z (about 2 months ago)
- Last Synced: 2026-04-29T05:28:39.127Z (about 2 months ago)
- Topics: cli, clipboard, copy-paste, go, golang
- Language: Go
- Homepage:
- Size: 727 KB
- Stars: 817
- Watchers: 14
- Forks: 30
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Notice: NOTICE.txt
Awesome Lists containing this project
- command-line-tools - pbgopy - Copy and paste between devices. (Other)
- awesome-cli-apps-in-a-csv - pbgopy - Copy and paste between devices. (<a name="transfer"></a>Data transfer)
- awesome-cli-apps - pbgopy - Copy and paste between devices. (<a name="transfer"></a>Data transfer)
- awesome-golang-repositories - pbgopy
README
# pbgopy
[](https://github.com/nakabonne/pbgopy/releases/latest)
[](https://pkg.go.dev/mod/github.com/nakabonne/pbgopy?tab=packages)
`pbgopy` acts like [pbcopy/pbpaste](https://www.unix.com/man-page/osx/1/pbcopy/) but for multiple devices. It lets you share data across devices like you copy and paste.

## Installation
Binary releases are available through [here](https://github.com/nakabonne/pbgopy/releases).
#### macOS
```
brew install nakabonne/pbgopy/pbgopy
```
#### RHEL/CentOS
```
rpm -ivh https://github.com/nakabonne/pbgopy/releases/download/v0.4.0/pbgopy_0.4.0_linux_amd64.rpm
```
#### Debian/Ubuntu
```
wget https://github.com/nakabonne/pbgopy/releases/download/v0.4.0/pbgopy_0.4.0_linux_amd64.deb
apt install ./pbgopy_0.4.0_linux_amd64.deb
```
#### Arch Linux
AUR package is available: [pbgopy](https://aur.archlinux.org/packages/pbgopy/)
```
yay pbgopy
```
#### Nix
```
nix-shell -p nixpkgs.pbgopy
```
#### Go
```
go install github.com/nakabonne/pbgopy@latest
```
#### Docker
```
docker run --rm nakabonne/pbgopy pbgopy help
```
## Usage
First up, you start the pbgopy server which works as a shared clipboard for devices. It listens on port 9090 by default.
You must allow access to this port for each device you want to share data with.
```bash
pbgopy serve
```
Populate the address of the host where the above process is running into the `PBGOPY_SERVER` environment variable. Then put the data entered in STDIN into the server with:
```bash
export PBGOPY_SERVER=http://host.xz:9090
pbgopy copy foo.png
```
## History of copies
To keep previous copies, start the server with a larger history limit:
```bash
pbgopy serve --history-limit 20
```
Each successful `copy` creates a new history entry and `paste` still returns the latest entry by default. You can list entries without printing full clipboard contents, paste a specific entry, or delete history:
```bash
$ pbgopy history
ID AGE TYPE SIZE LATEST PREVIEW
fcd0bc9afd9586c4544c377024d4e3b1 4s text/plain; charset=utf-8 6B * "world"
f9db4d7b8befb5d8b86b39e58b695126 9m image/jpeg 1.6MB JPEG image 3144x4192
$ pbgopy paste --id f9db4d7b8befb5d8b86b39e58b695126 >foo.jpg
```
The default history limit is `1`, which preserves the existing latest-only behavior. Give `--history-limit 0` for unlimited in-memory history.
## End-to-end encryption
`pbgopy` comes with a built-in ability to encrypt/decrypt with a variety of keys.
### With symmetric-key:
You can derive the key from password with the `-p` flag, which is provided so that you can encrypt/decrypt without previous setting.
```bash
pbgopy copy -p your-password foo.png
```
## From clipboard on your OS
You can put the data stored at the clipboard on your OS into pbgopy server.
```bash
pbgopy copy -c
```
## Command-line options
#### Copy
```
pbgopy copy -h
Copy from stdin
Usage:
pbgopy copy [flags]
Examples:
export PBGOPY_SERVER=http://host.xz:9090
echo hello | pbgopy copy
Flags:
-a, --basic-auth string Basic authentication, username:password
-c, --from-clipboard Put the data stored at local clipboard into pbgopy server
--gpg-path string Path to gpg executable (default "gpg")
-u, --gpg-user-id string GPG user id associated with public-key to be used for encryption
-h, --help help for copy
--max-size string Max data size with unit (default "500mb")
-p, --password string Password to derive the symmetric-key to be used for encryption
-K, --public-key-file string Path to an RSA public-key file to be used for encryption; Must be in PEM or DER format
-k, --symmetric-key-file string Path to symmetric-key file to be used for encryption
--timeout duration Time limit for requests (default 5s)
```
#### Paste
```
pbgopy paste -h
Paste to stdout
Usage:
pbgopy paste [flags]
Examples:
export PBGOPY_SERVER=http://host.xz:9090
pbgopy paste >hello.txt
pbgopy paste --id >hello.txt
Flags:
-a, --basic-auth string Basic authentication, username:password
--gpg-path string Path to gpg executable (default "gpg")
-u, --gpg-user-id string GPG user id associated with private-key to be used for decryption
-h, --help help for paste
--id string History entry id to paste
--max-size string Max data size with unit (default "500mb")
-p, --password string Password to derive the symmetric-key to be used for decryption
-K, --private-key-file string Path to an RSA private-key file to be used for decryption; Must be in PEM or DER format
--private-key-password-file string Path to password file to decrypt the encrypted private key
-k, --symmetric-key-file string Path to symmetric-key file to be used for decryption
--timeout duration Time limit for requests (default 5s)
```
#### History
```
pbgopy history -h
List clipboard history
Usage:
pbgopy history [flags]
pbgopy history [command]
Available Commands:
clear Delete all history entries
delete Delete a history entry
Examples:
export PBGOPY_SERVER=http://host.xz:9090
pbgopy history
pbgopy history --json
pbgopy history delete
pbgopy history clear
Flags:
-a, --basic-auth string Basic authentication, username:password
-h, --help help for history
--json Output history metadata as JSON
--timeout duration Time limit for requests (default 5s)
```
#### Serve
```
pbgopy serve -h
Start the server that acts like a clipboard
Usage:
pbgopy serve [flags]
Examples:
pbgopy serve --port=9090 --ttl=10m --history-limit=20
Flags:
-a, --basic-auth string Basic authentication, username:password
-h, --help help for serve
--history-limit int Number of clipboard entries to retain. Give 0 for unlimited history (default 1)
-p, --port int The port the server listens on (default 9090)
--ttl duration The time that the contents is stored. Give 0s for disabling TTL (default 24h0m0s)
```
## Inspired By
- [nwtgck/piping-server](https://github.com/nwtgck/piping-server)
- [bradwood/glsnip](https://github.com/bradwood/glsnip)