Report abuse

[OBSOLETE NOW] Straight from the horses mouth, by Allan Odgaard, author of TextMate


	
	

Edge TextMate has really cool pasting support that supports the full range of syntax hilighting and TM styles.

# you should create a new command in the bundle editor

paste_targets () {
   osascript <<"EOF"
      tell application "Colloquy"
         set AppleScript's text item delimiters to " "
         (name of chat room panels & name of direct chat panels) as string
      end tell
EOF
}

if [[ -z "$TM_IRC_CHANNEL" ]] && ps -xc|grep -sq 'Colloquy$'; then
  result=$(CocoaDialog dropdown \
    --title 'Paste to IRC' \
    --text 'Choose a chat room or user:' \
    --button1 Paste --button2 Cancel \
    --string-output --no-newline \
    --items $(paste_targets))

  if [[ "${result:0:5}" == "Paste" ]];
    then TM_IRC_CHANNEL="${result:6}"
    else exit_discard
  fi
fi

# set the language to one pastie supports
TM_LANG=$(cut <<<"$TM_SCOPE" -d. -f2)
case "$TM_LANG" in
	diff|javascript|ruby|sql|html)
		;;
	c++|objc|objc++)
		TM_LANG=c
		;;
	*)
		TM_LANG=plaintext
esac

url=$(curl http://pastie.caboo.se/pastes/create \
   -H "Expect:" \
   -F "paste[parser]=$TM_LANG" \
   -F "paste[body]=<-" \
   -s -L -o /dev/null -w "%{url_effective}" \
  2> >(CocoaDialog progressbar --indeterminate \
    --title "Paste to ${TM_IRC_CHANNEL}…" \
    --text "Contacting Server “${TM_PASTE_URL}”…" \
  ))

[[ -z "$url" ]] && exit_show_tool_tip "Error: Got no URL back from pasting service."

if ps -xc|grep -sq 'Colloquy$'; then
  osascript -e "tell application \"Colloquy\" to send message \"pasted $url\" action tense yes to target of item 1 of (panels where name = \"$TM_IRC_CHANNEL\")"
  echo "The text was pasted to $TM_IRC_CHANNEL."
else
  echo -n "$url" | pbcopy
  echo "The text is available as $url"
  echo "For your convenience, the URL was placed on the clipboard."
fi