#!/bin/csh -f # tweet # ----------------------------------------------------------------------------- # Shell script to tweet a message via Twitter, and log it. # ----------------------------------------------------------------------------- # Note: Need :q to avoid error: Unmatched ". # when I enter a multi-line string using backslash to escape newlines. if ("$1:q" == "-h" || "$1:q" == "--help") then echo "Usage: $0:t words optionally in a quoted string" echo " Putting double quotes around the whole string works best." echo " Can then use 'apostrophes', #hashtags, exclamation points\!, " echo " (parentheses), [square brackets], etc., and can backslash" echo " newlines. For some reason, {curly braces} and their content" echo " are still stripped out." echo " Double-quotes as part of the text cause an error." echo " For now, use single-quotes (apostrophes) instead." echo " You can edit the tweet once it appears in your browser before" echo " clicking the Tweet button." exit 1 endif set logfile = ~/fred/tweet.log if ($#argv == 0) then o http://twitter.com else # Stopped working when Twitter changed their URLs #open "http://twitter.com/home?status=$1:q+$2:q+$3:q+$4:q+$5:q+$6:q+$7:q+$8:q+$9:q+$10:q+$11:q+$12:q+$13:q+$14:q+$15:q+$16:q+$17:q+$18:q+$19:q+$20:q+$21:q+$22:q+$23:q+$24:q+$25:q+$26:q+$27:q+$28:q+$29:q+$30:q" # Doesn't tolerate pound signs ("#"), apostrophes ("'"), etc. # o "https://twitter.com/intent/tweet?text=$1:q+$2:q+$3:q+$4:q+$5:q+$6:q+$7:q+$8:q+$9:q+$10:q+$11:q+$12:q+$13:q+$14:q+$15:q+$16:q+$17:q+$18:q+$19:q+$20:q+$21:q+$22:q+$23:q+$24:q+$25:q+$26:q+$27:q+$28:q+$29:q+$30:q" #echo Raw args: #echo $*:q #echo "" # Tolerates everything except double quote chars (") set urlargs = `echo $*:q | urlencode` #echo Urlencoded: #echo $urlargs:q #echo "" o "https://twitter.com/intent/tweet?text=$urlargs" set timestamp = `date "+%Y/%m/%d %H:%M:%S"` echo "$timestamp $1:q $2:q $3:q $4:q $5:q $6:q $7:q $8:q $9:q $10:q $11:q $12:q $13:q $14:q $15:q $16:q $17:q $18:q $19:q $20:q $21:q $22:q $23:q $24:q $25:q $26:q $27:q $28:q $29:q $30:q" >>! $logfile endif