un pastis oui, un pastiche non !
Pastis is a simple but complete Ruby interface to Pastie. It lets you create, search or list pastes. A standalone script helps integration with the shell.
gem install pastis
Use cases
From shell
- open a new file in $EDITOR and pastes it on exit
pastis -
edit something.js and paste it (ruby is the default language)
pastis -e something.js -l javascript - make a private paste with STDIN
cat something.rb | pastis -p
From Ruby
1 2 3 4 5 6 7 8 |
paste = Pastis.paste a_string, :language => :text, :private => true puts paste.url, paste.body results = Pastis.search('mixin') puts results.first.body puts results.next_page.first.preview unless results.last_page? |
From TextMate
Open the bundle editor and add this command in Source bundle (Input: Selected Text or Document, Output: discard). It will paste selected text or entire document with correct syntax, and open it in a browser:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#!/usr/bin/env ruby require 'rubygems' require 'pastis' input = ENV['TM_SELECTED_TEXT'] || File.read(ENV['TM_FILEPATH']) languages = { /source\.ruby/ => :ruby, /text\.html\.basic/ => :html, /text\.html\.ruby/ => :rhtml, /source\.js/ => :javascript, /source\.(c|c\+\+)/ => :c, /source\.sql/ => :sql, /source\.diff/ => :diff } language = languages[languages.keys.find { |pattern| ENV['TM_SCOPE'] =~ pattern }] || :plaintext paste = Pastis.paste(input, :language => language) `open #{paste.url}` |
For further information, read the documentation.
Have fun !
0 comments