Skip to content

Instantly share code, notes, and snippets.

@shaneharter
Created June 28, 2012 23:31
Show Gist options
  • Save shaneharter/3014718 to your computer and use it in GitHub Desktop.
Save shaneharter/3014718 to your computer and use it in GitHub Desktop.
function bashrc() {
# If $script variable exists, use it as filename to append. If not, use $1
if [ -z "$script" ]
then fname="$1"
else fname="$script"
fi
if [ -z "$fname" ]
then return 1
fi
ln=`head -n 1 ./$fname`
if [ -z "$ln" ]
then return 1
fi
if grep -q "$ln" ~/.bashrc
then
echo "Sorry, $fname Is Already Installed, Playa"
return 1
fi
cp ~/.bashrc ~/.bashrc.bak
cat $fname >> ~/.bashrc
echo "WTG dude, $fname is installed now."
}
#And use it to install itself:
#!/bin/bash
# Use the bashrc appender to append itself
source bashrc
script="bashrc"
bashrc
echo "Usage:"
echo " bashrc [file]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment