Created
June 28, 2012 23:31
-
-
Save shaneharter/3014718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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