A pastis for pastie
September 30th, 2007
If you use pastie service to share code (or may be you are already addicted to it), Samuel Lebeau has released a perfect ruby gems to pastie anything in one command line.
It’s called pastis (if you are French you know what a Pastis:”http://en.wikipedia.org/wiki/Pastis” is :), it’s a great alcohol from south of France).
You can get details on his blog.
The best is you can add a command on TextMate to pastie selected text. When you workk remotely and you want to share code with co-workers it’s a great time saver.
Here is the command taken from his article:
1 2 #!/usr/bin/env ruby 3 require 'rubygems' 4 require 'pastis' 5 6 input = ENV['TM_SELECTED_TEXT'] || File.read(ENV['TM_FILEPATH']) 7 8 languages = { 9 /source\.ruby/ => :ruby, 10 /text\.html\.basic/ => :html, 11 /text\.html\.ruby/ => :rhtml, 12 /source\.js/ => :javascript, 13 /source\.(c|c\+\+)/ => :c, 14 /source\.sql/ => :sql, 15 /source\.diff/ => :diff 16 } 17 18 language = languages[languages.keys.find { |pattern| ENV['TM_SCOPE'] =~ pattern }] || :plaintext 19 20 paste = Pastis.paste(input, :language => language) 21 22 `open #{paste.url}` 23