Skip to content

CLI

The Pastebox CLI (@pastebox/cli) lets you create, retrieve, list, and delete pastes from the command line. It supports end-to-end encryption and piping from stdin.

Installation

bash
# From the monorepo root
pnpm install
pnpm --filter @pastebox/shared build
pnpm --filter @pastebox/cli build

# Link the binary globally
cd apps/cli
pnpm link --global

After linking, the pastebox command is available in your shell.

Configuration

Before using the CLI, configure the server URL and API key:

bash
pastebox config --url https://paste.example.com --api-key pb_<your-key>

Configuration is saved to ~/.pastebox.json. You can set the URL and API key separately:

bash
pastebox config --url https://paste.example.com
pastebox config --api-key pb_<your-key>

View current configuration:

bash
pastebox config
# Config saved.
# URL:     https://paste.example.com
# API Key: pb_aBcDeF...

The default server URL is http://localhost:3000 if not configured.

Commands

create

Create a new paste from a file or stdin.

pastebox create [options]
OptionDescription
-f, --file <path>Read content from a file
-t, --title <title>Set paste title
-s, --syntax <lang>Syntax highlighting language (default: plaintext)
--ttl <seconds>Time-to-live in seconds (paste auto-expires)
--burnBurn after read (paste is deleted after first view)
--e2eeEnable end-to-end encryption (client-side)

Examples:

bash
# From a file
pastebox create --file script.py --syntax python --title "My Script"

# With TTL (1 hour)
pastebox create --file notes.txt --ttl 3600

# Burn after read
pastebox create --file secret.txt --burn --title "One-time secret"

get

Retrieve a paste by its public ID.

pastebox get <publicId> [options]
OptionDescription
--key <key>E2EE decryption key (base64url-encoded)

Examples:

bash
# Get a standard paste (Mode A -- server decrypts)
pastebox get aBcDeFgHiJkLmNoPqRsTuVwXyZ012345

# Get an E2EE paste (Mode B -- client decrypts)
pastebox get aBcDeFgHiJkLmNoPqRsTuVwXyZ012345 --key <base64url-key>

list

List your pastes. Requires an API key.

pastebox list [options]
OptionDescription
-l, --limit <n>Max number of results to return

Example:

bash
pastebox list
# aBcDeFgH...  My Script    python        2025-01-15T10:30:00Z
# xYzAbCdE...  (untitled)   plaintext     2025-01-14T08:00:00Z

pastebox list --limit 5

delete

Delete a paste by its public ID. Requires an API key. You can only delete your own pastes.

pastebox delete <publicId>

Example:

bash
pastebox delete aBcDeFgHiJkLmNoPqRsTuVwXyZ012345
# Paste deleted.

E2EE Usage

When creating a paste with --e2ee, the CLI encrypts the content locally before sending it to the server. The decryption key is appended to the URL as a fragment.

bash
# Create an E2EE paste
pastebox create --file secret.txt --e2ee --title "Encrypted Note"
# Paste created!
# URL:       https://paste.example.com/p/aBcDeFgH...#rAnDoMkEyHeRe
# Public ID: aBcDeFgHiJkLmNoPqRsTuVwXyZ012345
# E2EE key is in the URL fragment -- keep the full URL to decrypt.

The full URL (including the #key fragment) must be shared for the recipient to decrypt the paste. The fragment is never sent to the server.

To retrieve an E2EE paste via CLI, you need to provide the key explicitly:

bash
# Extract the key from the URL fragment and pass it with --key
pastebox get aBcDeFgH... --key rAnDoMkEyHeRe

In a web browser, the JavaScript on the paste view page reads the key from window.location.hash and decrypts in the browser automatically.

Pipe from stdin

Content can be piped directly from other commands:

bash
# Pipe command output
cat /var/log/app.log | pastebox create --syntax log --title "App logs"

# Pipe a diff
git diff | pastebox create --syntax diff --title "My changes"

# Pipe with E2EE
echo "super secret" | pastebox create --e2ee

# Clipboard (macOS)
pbpaste | pastebox create --syntax javascript

# Clipboard (Linux with xclip)
xclip -selection clipboard -o | pastebox create

When stdin is not a TTY (i.e., data is piped), the CLI reads from stdin automatically. If stdin is a TTY and no --file is provided, the CLI exits with an error.

Self-hosted paste service with E2EE