Skip to content

Instantly share code, notes, and snippets.

@MikeGrace
Created June 14, 2010 04:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeGrace/437280 to your computer and use it in GitHub Desktop.
Save MikeGrace/437280 to your computer and use it in GitHub Desktop.
Shell script sets up bash .profile to show growl notification on 'krl commit'
#!/bin/bash
# Copyright 2010 Michael Grace
# http://geek.michaelgrace.org
# Created 06/13/2010
clear
echo "Script created by Mike Grace http://www.google.com/profiles/themikegrace"
echo "========================================================================"
echo ""
# check if script is run as root or with sudo
if [[ $(id -u) -ne 0 ]];
then
echo "This script won't work unless it is run using 'sudo' or run as root user"
echo "Please run the script again using 'sudo'"
exit
else
# check if growlnotify is installed and install if not
if [[ ! -e "/usr/local/bin/growlnotify" ]]; then
echo "growlnotify was not found on your system"
echo "installing growlnotify"
# some of the following steps taken from growlnotify install.sh
echo "Creating /usr/local/bin"
sudo mkdir -p /usr/local/bin
echo "Creating /usr/local/man/man1"
sudo mkdir -p /usr/local/man/man1
echo "Getting growlnotify version 1.2"
echo ""
sudo curl https://kynetx-apps.s3.amazonaws.com/krl-commit-growl-notify/growlnotify > /usr/local/bin/growlnotify
sudo curl https://kynetx-apps.s3.amazonaws.com/krl-commit-growl-notify/growlnotify.1 > /usr/local/man/man1/growlnotify.1
echo ""
echo "setting growlnotify to work with system"
sudo chmod +x /usr/local/bin/growlnotify
echo "adding /usr/local/bin to your PATH"
echo "export PATH=\"/usr/local/bin:$PATH\"" >> ~/.profile
echo "Reloading your Bash .profile"
source ~/.profile
echo "GrowlNotify installation complete!"
echo "If you don't also see the previous message in a growl notification something went wrong and you should manually install growlnotify"
growlnotify -t "Woot!" -m "GrowlNotify installation complete!" -s
echo ""
echo "-----------------"
echo ""
fi
# setup growl notifications for krl commit
echo "Appending function to .profile for growl notification goodness"
# append function to .profile for bash
echo "" >> ~/.test
echo "" >> ~/.test
echo "# auto appended by script created by @MikeGrace for growl notifications on 'krl commit' http://www.google.com/profiles/themikegrace" >> ~/.test
echo "# Use growlnotify to alert user of commit status" >> ~/.test
echo "krl() { if [[ $@ == \"commit\" ]]; then command krl commit | tee status.txt | growlnotify -t \"KRL\" --image /kynetx-x.png; cat status.txt; else command krl $@ fi;}" >> ~/.test
echo "# Done setting up growlnotify to work with krl commit" >> ~/.test
echo "" >> ~/.test
echo "Reloading .profile"
source ~/.profile
# get growl notify image to be used
echo "Getting Kynetx growl image"
echo ""
curl https://kynetx-apps.s3.amazonaws.com/krl-commit-growl-notify/kynetx-x.png > /kynetx-x.png
echo ""
echo "You are ready to go!"
growlnotify -m "You are ready to go!" --image /kynetx-x.png -s -t "Woohoo!"
echo ""
echo " Script complete"
echo "========================================================================"
echo ""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment