Skip to content

Instantly share code, notes, and snippets.

@tekkub
Forked from defunkt/.bashrc
Created August 21, 2009 00:03
Show Gist options
  • Save tekkub/171531 to your computer and use it in GitHub Desktop.
Save tekkub/171531 to your computer and use it in GitHub Desktop.
Tweet from bash shell, with length check
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
string=$*
LEN=$(echo ${#string})
if [ $LEN -gt 140 ]; then
echo "You talk too much ($LEN chars)"
else
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"
fi
}
# put this in ~/.netrc
machine twitter.com
login USERNAME
password PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment