add some doc to sprunge
[xo.git] / twitter
blob5a0302ee7cd2b79975630524dfa575234ac63eb4
1 #!/bin/bash
2 # a twitter client (uses .netrc for authentication)
4 [ "$1" == "-h" ] && {
5 echo " use: $(basename $0) -h | [ tweet ]"
6 echo " -h help"
7 echo " no arguments gets latest updates"
8 exit
11 function friends {
12 curl --connect-timeout 5 -s -n $1 | awk '
14 sub(/^[^>]*>/,"",$0)
15 gsub(/lt;/,"<",$0)
16 gsub(/gt;/,">",$0)
17 gsub(/&amp;/,"",$0)
19 /text/ { sub(/<[^<]*>$/,"",$0); m=$0 }
20 /created_at/ { sub(/<[^<]*>$/,"",$0); at=$0 }
21 /_name/ { sub(/<[^<]*>$/,"",$0); x[++i] = $0 " : " m "\n\t[" at "]" }
22 END { for(j=i;j>0;j--) print x[j] }
26 function update {
27 curl -s -n -d "status=$msg" $1 &>/dev/null || echo "tweet broke"
30 if [ -t 0 ];then msg="$*";else msg="$(cat -)";fi
32 if [ "$msg" ];then
33 update http://twitter.com/statuses/update.xml
34 else
35 friends http://twitter.com/statuses/friends_timeline.xml