Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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]"
Add Comment
Please, Sign In to add comment