Tip #768 Stream shell commands to Twitter
When I read the tip yesterday (Twitter from the terminal), I thought it would be fun to set something up to tweet all the commands I enter. After a bit of playing around I have come up with the following:First you'll need to create a script, it doesn't matter what you call it, just remember the name and path to it for later.
#!/bin/bash read MSG echo $MSG > characters length=$(wc -c characters | sed 's/^[^0-9]*\([0-9]*\)[^0-9]*$/\1/') if [ $length -le 140 ]; then wget -q --keep-session-cookies --http-user=YOURUSER --http-password=YOURPASS \ --post-data="status=$MSG" \ https://twitter.com/statuses/update.xml; fi
You'll need to replace YOURUSER and YOURPASS as appropriate, and if you prefer to use identi.ca then change the twitter url to https://identi.ca/api/statuses/update.xml
Next run the following command, changing details at the end for the script you just created (note this does require you to use bash):
export PROMPT_COMMAND='echo "$(history 1)" | sed "s/^ *[0-9]* *//" | /path/to/script.sh'
Now every command you type will be sent to twitter! To turn this off, just run "export PROMPT_COMMAND=''" or logoff. Of course this isn't really a good idea to do all the time, though it is fun! Also remember that Twitter will block accounts that post over 100 updates per hour.
An example of the results can be seen here: https://twitter.com/ShellStream
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs