Skip to content

yesabhishek/pastebin-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pb

pb is a GitHub-backed personal pastebin CLI for small notes and images.

It stores files in a dedicated private GitHub repository, keeps a local cache for offline edits, autosaves text drafts locally while you work, and gives you explicit save/sync commands plus per-file version history.

Features

  • GitHub-backed file storage with local-first caching and recovery
  • built-in terminal editor with local draft autosave and Ctrl+V image paste
  • clipboard image paste/copy commands for screenshots and photos
  • explicit sync flow for reconciling changes across devices
  • durable per-file version history with show and restore commands
  • built-in release checks with saved upgrade preferences
  • conflict copies instead of risky remote overwrites
  • installable without sudo or admin rights

Requirements

  • Go 1.25+ if you want to build from source
  • GitHub CLI installed and authenticated with gh auth login

Install From Releases

macOS and Linux:

curl -fsSL https://raw.githubusercontent.com/yesabhishek/pastebin-cli/main/scripts/install.sh | sh

Windows PowerShell:

iwr https://raw.githubusercontent.com/yesabhishek/pastebin-cli/main/scripts/install.ps1 -useb | iex

These installers place the binary in a user-owned bin directory, so no sudo or admin rights are required.

Build From Source

git clone https://github.com/yesabhishek/pastebin-cli.git
cd pastebin-cli
go build -o pb ./cmd/pb

Local Checks

Install the local sanity-check tools first:

brew install actionlint shellcheck
git config core.hooksPath .githooks

Then run the same checks locally that CI uses:

./scripts/check.sh

Quick Start

./pb init
./pb version
./pb new notes/today.txt
./pb paste photos/screenshot
./pb copy photos/screenshot.png
./pb versions notes/today.txt
./pb list
./pb sync

pb init uses your current gh login and creates a dedicated private storage repository, pastebin-cli-store, by default.

Commands

pb init
pb version
pb new <path>
pb edit <path>
pb read <path> [--out <file>]
pb paste <path>
pb copy <path>
pb versions <path>
pb show <path> <version-id>
pb restore <path> <version-id>
pb delete <path> [--yes]
pb list [prefix] [--refresh]
pb sync
pb status
pb upgrade [--yes] [--check] [--policy prompt|auto|manual]
pb logout

Global flags:

  • --repo <name>: override the default GitHub storage repo
  • --json: emit JSON for read, versions, show, list, and status

Images And Clipboard

  • pb paste <path> saves the current OS clipboard image as PNG content. If <path> has no image extension, pb appends .png.
  • pb copy <path> copies stored images back to the OS clipboard. Text files are copied as text.
  • Ctrl+V in the editor saves a clipboard image to the current path when the text buffer is clean.
  • pb read <image> opens stored images in the default image viewer.
  • pb read <path> --out <file> writes raw bytes to a file, which is the safest way to script image or binary reads.
  • Clipboard support depends on desktop clipboard access. Linux support is X11-oriented; Wayland sessions may need XWayland/DISPLAY.

Editor shortcuts:

  • Ctrl+S: save
  • Ctrl+Q or Ctrl+X: save and quit
  • Ctrl+V: paste clipboard image when the buffer has no unsaved text

Release Updates

  • pb checks GitHub for a newer release about once a day after you have run pb init
  • when an update is available, you can upgrade now, always auto-upgrade, skip that release, or turn prompts off
  • pb upgrade --check checks whether a newer release exists
  • pb upgrade --yes installs the latest published release immediately
  • pb upgrade --policy auto|prompt|manual saves your upgrade preference
  • pb version prints the currently running CLI version

Version History

  • pb versions <path> lists durable synced versions for a file, newest first
  • pb show <path> <version-id> prints the content of a historical version
  • pb restore <path> <version-id> restores a historical version as the latest one

Durable versions are created on explicit save, save-on-exit, restore, and sync. The editor's background autosave only protects local drafts and does not create remote version spam.

Local Data Layout

pb stores app-owned local state under your user config directory:

  • config.json: repo/login/device settings
  • state/index.json: tracked file metadata
  • state/journal.json: resumable pending operations
  • state/recovery/: autosave recovery snapshots
  • cache/files/: cached text content

Project Files

About

GitHub-backed personal pastebin CLI with autosave, local cache, and sync.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors