Created
December 9, 2014 19:38
-
-
Save avalanche123/619a70d72d3c5b8b2d8d to your computer and use it in GitHub Desktop.
TextMate2 CopyWithStyle action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
source "$TM_SUPPORT_PATH/lib/bash_init.sh" # might not be necessary | |
read -r -d '' code <<-'EOF' | |
require "jcode" if RUBY_VERSION < '1.9' | |
app_path = ENV["TM_SUPPORT_PATH"] | |
require "#{app_path}/../../../TextMate.tmbundle/Support/lib/doctohtml.rb" | |
require "#{app_path}/lib/progress.rb" | |
unit = ENV.has_key?('TM_SELECTED_TEXT') ? 'selection' : 'document' | |
TextMate.call_with_progress(:message => "Creating HTML version of #{unit}...") do | |
print document_to_html( STDIN.read, :include_css => true ) | |
end | |
EOF | |
ruby18 -e "$code" | textutil -format html -convert rtf -stdin -stdout | pbcopy | |
echo 'Done!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment