Share Code Snippets Easily From the Command Line

This is a great tip I found at commandlinefu to easily share code snippets write from the command line.

First, you may want to add this to your aliases file:

1
alias share='curl -F "sprunge=<-" http://sprunge.us | xclip'

(If you don’t have the xclip program, you can easily install it from your package manager.)

Now, say that you have a c program named “hello.c”, to share it, type this (after reloading your aliases file of course):

cat hello.c | share

Now, the code is already in the internet, and the URL is in your clipboard. Go to firefox and click the middle mouse button in the URI area. You’ll see a URL similar to this:

http://sprunge.us/BaFS



To view the code with syntax highlighting and line numbers, just append “?c? (or “?lang” where ‘lang’ is the relevant programming language). So the final URL should look like this:

http://sprunge.us/BaFS?c

Enjoy ;)

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to Ping.fm Post to Reddit Post to StumbleUpon

Related posts:

  1. Tiny Bash Functions to Convert Between Numeric Representations
  2. Modify Ctrl-Alt-Del Behavior in Linux
  3. Send Email from the Command Line using Gmail Account
  4. Send Self Reminders To Your Email From The Command Line
  5. Create a Directory Tree With One Command

Tags: , , ,

Saturday, June 13th, 2009 Programming

Leave a Reply

my email
Already a member?
Login
Login using Facebook:
Last visitors
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and am currently studying for a BSc. in electrical engineering at The Electrical Engineering school , Technion , Israel.
I work at the verification dept. in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
June 2009
S M T W T F S
« May   Jul »
 123456
78910111213
14151617181920
21222324252627
282930  
Linux Inside
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.