Many a time while working it is convenient to quickly show someone else code or a chunk of output from some command. The easiest way to do this is through a pastebin service. It’s also pretty much mandated on IRC to use a service like this and there are literally thousands out there to choose from.
The gist service on github is actually fairly convenient especially if you have a github account since it keeps an archive of all of your previous gists. It also does a good job formatting and lets you paste privately. We’ll use the App::Nopaste tool to paste a gist straight from the command line.
First off install the tool from cpan
$ cpan App::Nopaste
You can use this tool anonymously but if you want to keep an archive of your pastes you can simply setup your git credentials in your .gitconfig file. The token here is your API token which can be found under your account settings page.
[github] user = jgoulah token = 00000000000000000000000000000000
You also need either Git installed or Config::INI::Reader to allow the module to read your .gitconfig file.
Now to make this a bit easier to remember we can create an alias in our .bashrc file. In this case I’m specifying –private so that only people that I give this secure URL out to can see, and I’m also specifying to use the Gist service. The nopaste app supports a variety of other services that you can use but as of this writing Gist is the only one that supports the –private flag.
alias gist='nopaste --private --service Gist'
Now you can use the command to paste something such as a script from the command line and the gist URL is returned
$ gist somescript.sh http://gist.github.com/df552bacbbbb8d70c089
There you have it!