January 5, 202610 min read

How to Share Code from Terminal: 7 CLI Tools Compared

You're in the terminal, you've got code you need to share—maybe a script, config file, error log, or output from an AI assistant. Opening a browser feels like context-switching overhead. You want a URL, and you want it fast.

This guide covers 7 ways to share code directly from your terminal, from one-liners to full-featured tools.

Quick Reference

# Fastest (no formatting)
cat file.py | curl -F 'f:1=<-' ix.io

# Best formatting (Claude Code)
/markshare

# GitHub ecosystem
gh gist create file.py

# Self-destructing
cat file.py | curl -F 'file=@-' https://0x0.st

Method 1: ix.io (One-Line Sharing)

The simplest pastebin that works from any terminal.

Basic Usage

# Share a file
cat script.py | curl -F 'f:1=<-' ix.io
# Returns: http://ix.io/4abc

# Share with syntax highlighting hint
cat script.py | curl -F 'f:1=<-' -F 'ext:1=py' ix.io

# Share command output
ls -la | curl -F 'f:1=<-' ix.io

# Share clipboard (macOS)
pbpaste | curl -F 'f:1=<-' ix.io

Add to Shell Config

# Add to ~/.bashrc or ~/.zshrc
ix() {
  curl -F 'f:1=<-' ix.io
}

# Usage
cat file.py | ix

Pros:

  • No account required
  • Works everywhere curl works
  • Memorable syntax

Cons:

  • Basic syntax highlighting
  • No editing after post
  • Plain appearance

Best for: Quick throwaway shares, piping command output.


Method 2: paste.rs (Rust-Powered)

Lightweight paste service with clean URLs.

Basic Usage

# Share a file
cat file.py | curl -X POST -d @- https://paste.rs
# Returns: https://paste.rs/abc

# Share from stdin
echo "Hello, world!" | curl -X POST -d @- https://paste.rs

# With expiration (syntax varies)
cat file.py | curl -X POST -d @- https://paste.rs

Shell Function

# Add to shell config
paste() {
  curl -X POST -d @- https://paste.rs
}

# Usage
cat config.yaml | paste

Pros:

  • Clean URLs
  • Fast
  • No JavaScript required to view

Cons:

  • No syntax highlighting
  • Links may expire
  • Minimal features

Best for: Sharing plain text quickly, CI/CD scripts.


Method 3: GitHub Gist CLI

Share code through GitHub's infrastructure using the official CLI.

Setup

# Install GitHub CLI
brew install gh  # macOS
sudo apt install gh  # Ubuntu

# Authenticate
gh auth login

Usage

# Create public gist
gh gist create file.py

# Create secret (unlisted) gist
gh gist create --secret file.py

# Create with description
gh gist create -d "My utility script" file.py

# Create from stdin
echo "print('hello')" | gh gist create -f hello.py

# Create multi-file gist
gh gist create file1.py file2.py file3.py

# List your gists
gh gist list

# View a gist
gh gist view <gist-id>

# Edit a gist
gh gist edit <gist-id>

Shell Alias

# Quick gist creation
alias gist='gh gist create'
alias gists='gh gist list'

Pros:

  • Version history
  • Editing after creation
  • Good syntax highlighting
  • Familiar to developers

Cons:

  • Requires GitHub account
  • Requires authentication
  • More verbose than pastebins

Best for: Code you might update, sharing with GitHub users.

GitHub CLI Docs → | GitHub Gist Alternatives →


Method 4: Markshare (Best Formatting)

For code that needs to look professional—documentation, tutorials, AI-generated content.

From Claude Code

# Share current context with one command
/markshare

The output gets:

  • Syntax highlighting (Shiki, same as VS Code)
  • Automatic table of contents
  • Mermaid diagram rendering
  • Mobile-responsive layout

[SCREENSHOT: Markshare rendered code with syntax highlighting]

Why It's Different

Most terminal paste tools output plain text or basic HTML. Markshare renders markdown the way you'd want to present it:

Traditional pastebin:
def hello():
    print("Hello, world!")

Markshare:
[Shiki syntax highlighting + clickable TOC + Mermaid diagrams]

Pros:

  • Best-in-class code rendering
  • Handles markdown + code together
  • Private/expiring links available
  • Built for AI assistant output

Cons:

  • Best experience in Claude Code
  • Newer tool

Best for: Sharing polished code documentation, AI-generated code, tutorials.

Need to clean up terminal output before sharing? Try our Terminal Output Formatter.

Try Markshare →


Method 5: 0x0.st (Self-Destructing)

For temporary shares that auto-delete.

Usage

# Upload file (expires based on size, max 1 year)
curl -F 'file=@script.py' https://0x0.st
# Returns: https://0x0.st/abc.py

# Upload from stdin
cat file.py | curl -F 'file=@-' https://0x0.st

# Shorter retention
curl -F 'file=@bigfile.tar' -F 'expires=1' https://0x0.st  # 1 hour

Retention Rules

  • Smaller files last longer (up to 1 year)
  • Larger files expire sooner
  • Max file size: 512MB

Pros:

  • Auto-deletion
  • Handles binary files
  • No account
  • Good for sensitive data

Cons:

  • No syntax highlighting
  • Can't extend expiration
  • No editing

Best for: Temporary shares, sensitive code, large files.


Method 6: termbin.com (Netcat Simple)

The most minimal option—just netcat.

Usage

# Share using netcat
cat file.py | nc termbin.com 9999
# Returns: https://termbin.com/abc

# One-liner from command output
echo "Hello" | nc termbin.com 9999

Shell Function

tb() {
  nc termbin.com 9999
}

# Usage
cat script.sh | tb

Pros:

  • Works without curl
  • Extremely minimal
  • Fast

Cons:

  • Very basic
  • No formatting
  • Port 9999 might be blocked

Best for: Minimal environments, when curl isn't available.


Method 7: Wgetpaste (Multi-Service)

A wrapper that can post to multiple paste services.

Setup

# Install
# Arch Linux
sudo pacman -S wgetpaste

# From source
git clone https://github.com/zlin/wgetpaste

Usage

# Share file
wgetpaste file.py

# Share stdin
cat file.py | wgetpaste

# Choose service
wgetpaste -s dpaste file.py    # dpaste.org
wgetpaste -s ix file.py        # ix.io
wgetpaste -s bpaste file.py    # bpaste.net

# With syntax highlighting
wgetpaste -l python file.py

# List available services
wgetpaste -S

Pros:

  • Multiple services in one tool
  • Syntax highlighting support
  • Configurable

Cons:

  • Need to install
  • Some services may be unreliable

Best for: Power users who want flexibility.

For a broader look at markdown tools, see our Markdown Sharing Tools for Developers guide.


Comparison Table

ToolSpeedFormattingAccountBinaryExpiration
ix.ioFastBasicNoNoNo
paste.rsFastNoneNoNoMaybe
gh gistMediumGoodYesNoNo
MarkshareFastExcellentOptionalNoOptional
0x0.stFastNoneNoYesAuto
termbinFastNoneNoNoNo
wgetpasteMediumBasicNoNoVaries

Shell Setup Recommendations

Add these to your ~/.bashrc or ~/.zshrc:

# Quick paste to ix.io
ix() {
  local file="${1:-/dev/stdin}"
  curl -F "f:1=@$file" ix.io
}

# paste.rs shortcut
pasters() {
  curl -X POST -d @- https://paste.rs
}

# GitHub gist shortcuts
alias gist='gh gist create'
alias gist-secret='gh gist create --secret'
alias gists='gh gist list'

# 0x0.st for temp sharing
0x0() {
  curl -F "file=@${1:--}" https://0x0.st
}

# Copy URL to clipboard automatically (macOS)
share() {
  local url=$(cat "$1" | curl -F 'f:1=<-' ix.io)
  echo "$url" | pbcopy
  echo "Copied: $url"
}

Git Integration

Share Diffs

# Share uncommitted changes
git diff | curl -F 'f:1=<-' ix.io

# Share diff between branches
git diff main..feature | gh gist create -f diff.patch

# Share last commit
git show HEAD | curl -F 'f:1=<-' ix.io

Pre-Push Hook

#!/bin/bash
# .git/hooks/pre-push
# Share changes for review before pushing

diff_url=$(git diff origin/main..HEAD | curl -s -F 'f:1=<-' ix.io)
echo "Review changes before push: $diff_url"
read -p "Continue? (y/n) " -n 1 -r
echo
[[ $REPLY =~ ^[Yy]$ ]] || exit 1

CI/CD Integration

GitHub Actions

name: Share Build Output

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Build
        run: make build 2>&1 | tee build.log

      - name: Share build log on failure
        if: failure()
        run: |
          URL=$(cat build.log | curl -s -F 'f:1=<-' ix.io)
          echo "Build log: $URL"

Share Test Results

#!/bin/bash
# run-tests.sh

pytest --tb=short 2>&1 | tee test-output.txt

if [ ${PIPESTATUS[0]} -ne 0 ]; then
  URL=$(cat test-output.txt | curl -s -F 'f:1=<-' ix.io)
  echo "Tests failed. Full output: $URL"
fi

Security Considerations

What Not to Share

Never paste:

  • API keys or tokens
  • Passwords or credentials
  • Private SSH keys
  • Environment files (.env)
  • Database connection strings

For Sensitive Code

  1. Use secret gists (unlisted, not encrypted):

    gh gist create --secret sensitive.py
    
  2. Use 0x0.st with short expiration for temporary shares

  3. Use Markshare private links for controlled access

  4. Self-host a paste service for full control (PrivateBin, Stikked)

Before Sharing

# Check for secrets before sharing
grep -E "(api_key|password|secret|token)" file.py

FAQ

What's the fastest way to share code from terminal?

For raw speed: cat file | curl -F 'f:1=<-' ix.io

For speed + good formatting: Markshare's /markshare command in Claude Code

How do I share code with syntax highlighting from terminal?

GitHub Gist (gh gist create) has good highlighting. Markshare has the best highlighting using Shiki. Most curl-based pastebins have basic or no highlighting.

Can I delete/edit code after sharing?

  • GitHub Gist: Yes, full editing and deletion
  • Markshare: Yes, can delete from dashboard
  • Pastebins (ix.io, paste.rs): Generally no

How do I share binary files from terminal?

Use 0x0.st: curl -F 'file=@binary.tar.gz' https://0x0.st

Most text pastebins don't support binary files.

Is there a self-hosted option?

Yes:

  • PrivateBin: End-to-end encrypted
  • Stikked: Simple PHP paste
  • Hastebin: Node.js paste server

Which tool works offline?

None of these—they all require internet. For offline "sharing," save to a file and transfer via USB, email, or local network.


Conclusion

For everyday terminal code sharing:

  • Quickest: cat file | curl -F 'f:1=<-' ix.io
  • Best formatting: Markshare (especially from Claude Code)
  • GitHub integration: gh gist create
  • Temporary/sensitive: 0x0.st

Pick based on your needs: speed vs. formatting vs. features. For most developers, having gh gist create and a quick pastebin alias covers 95% of use cases. For polished documentation or AI-generated code, Markshare's formatting is worth the extra step.

Try Markshare for Better Code Sharing →


Last updated: January 2026


SEO Metadata

Title tag (52 chars): How to Share Code from Terminal: 7 CLI Tools Compared

Meta description (158 chars): Share code from your terminal without leaving the command line. Compare ix.io, GitHub Gist, Markshare, and more. Find the fastest CLI tool for code sharing.

URL slug: /blog/how-to-share-code-from-terminal

Primary keyword: how to share code from terminal Secondary keywords: terminal paste, share code cli, command line paste, terminal code sharing

Ready to Share Markdown Beautifully?

Join developers who share AI-generated content and documentation with one command.

Try markshare Free