Guest User

Untitled

a guest
Nov 19th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. function bashrc() {
  2. # If $script variable exists, use it as filename to append. If not, use $1
  3. if [ -z "$script" ]
  4. then fname="$1"
  5. else fname="$script"
  6. fi
  7.  
  8. if [ -z "$fname" ]
  9. then return 1
  10. fi
  11.  
  12. ln=`head -n 1 ./$fname`
  13. if [ -z "$ln" ]
  14. then return 1
  15. fi
  16.  
  17. if grep -q "$ln" ~/.bashrc
  18. then
  19. echo "Sorry, $fname Is Already Installed, Playa"
  20. return 1
  21. fi
  22.  
  23. cp ~/.bashrc ~/.bashrc.bak
  24. cat $fname >> ~/.bashrc
  25. echo "WTG dude, $fname is installed now."
  26. }
  27.  
  28.  
  29. #And use it to install itself:
  30.  
  31. #!/bin/bash
  32. # Use the bashrc appender to append itself
  33.  
  34. source bashrc
  35. script="bashrc"
  36. bashrc
  37.  
  38. echo "Usage:"
  39. echo " bashrc [file]"
Add Comment
Please, Sign In to add comment