Skip to content

dblevins/gistpaste

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 

Repository files navigation

Note

Use the defunkt gist script. It now has all the same features and is better maintained -- for very obvious reasons.

Leaving this page here as historic reference.

Gistpaste: Command line paste script

This script can do all that the [defunkt gist script](http://github.com/defunkt/gist can:

  • paste a file
  • paste from stdin
  • authenticate
  • copy URL to clipboard

Plus a few things it can't:

  • paste multiple files at once
  • paste clipboard output
  • post anonymously even if a global git config exists
  • specify file name
  • specify file type
  • optionally open paste URL in browser

This script cannot "read" gists like defunkt's script can. I plan to create a gistcopy script for that at some point.

Installation

Download and install

wget http://github.com/dblevins/gistpaste/raw/master/gistpaste &&
chmod 755 gistpaste &&
sudo mv gistpaste /usr/local/bin/

Add any Perl modules you may not have

sudo cpan LWP::UserAgent

And an optional module if your system's "which" command is disabled for security reasons

sudo cpan File::Which

Usage

gistpaste [options] [FILE...]

Paste file(s)

gistpaste thatfile.txt another.diff

Paste STDIN

grep "this" thatfile.txt | gistpaste

Paste the clipboard contents

gistpaste -c

Authentication

Authentication is not required -- and can be shut off for a paste even once enabled -- but if you'd like to paste as yourself rather than anonymously, just setup your global git config like so:

git config --global github.user "your-github-username"
git config --global github.token "your-github-token"

You can find your GitHub username and token at https://github.com/account by clicking the 'Global Git Config' link.

Options

  • -h or --help

Display the usage and exit.

  • -m or --man

Display the man page and exit.

  • -p or --private

Paste privately

  • -a or --anonymous

Do not use a username when posting. This is the default when there is no authentication information setup.

  • -n or --name

Specifies the desired file name for data read from STDIN or the clipboard. When supplied along with files listed as arguments, the parameter will be given as the file name instead of the name of the file as it exists on the system.

  • -t or --type

Specifies the desired content type of the data pasted to Gist, either via STDIN, the clipboard or file. Gist will often ignore this parameter in favor of guessing the type based on the file name.

  • -c or --clipboard

Reads and posts data from the clipboard via pbpaste or xclip if available.

  • -o or --open

Open the URL in a browser after pasting. Supported via the open command (Mac OSX), or the xdg-open command (Linux) if either are available.

Examples

Paste a single file

gistpaste thatfile.txt

Paste multiple files of varying types

gistpaste thatfile.txt Some.java another.pl

Paste a single file and override the name, all functionally equivalent.

gistpaste --name=thatfile.diff thatfile.txt
gistpaste --name=thatfile.diff < thatfile.txt
cat thatfile.txt | gistpaste --name=thatfile.diff

Paste from STDIN

grep "this" thatfile.txt | gistpaste
svn diff thatfile.txt | gistpaste -t diff 
gistpaste < thatfile.txt

Copy content to the system clipboard and paste it

gistpaste -c
gistpaste -c -t xml
gistpaste -c -n mydata.xml

Paste a file without the name so Gist will not ignore the type parameter

gistpaste --name=" " -t diff thatfile.txt
gistpaste -t diff < thatfile.txt
cat thatfile.txt | gistpaste -t diff

Author

David Blevins [email protected]

About

Command line paste tool for gist.github.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published