Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shell script sets up bash .profile to show growl notification on 'krl commit'
# Copyright 2010 Michael Grace
# Created 06/13/2010
echo "Script created by Mike Grace"
echo "========================================================================"
echo ""
# check if script is run as root or with sudo
if [[ $(id -u) -ne 0 ]];
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'"
# 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
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 > /usr/local/bin/growlnotify
sudo curl > /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 ""
# 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'" >> ~/.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 > /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 ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment