Sunday, March 27, 2011

The Clockwork PC BASH script generator

Here is a little BASH script I wrote to automate the process of writing a BASH script.
To use it, open a terminal and enter the following commands:

mkdir ~/Documents/bin
gedit ~/Documents/bin/cpcbash.sh


Then paste the following text into the text files.


#!/bin/bash
#cpcbash.sh
#Released under a GPLv3 Licence by Clockwork PC (2011)
#BASH script to generate BASH scripts


echo "What do you want to call your BASH script?"
read RESPONSE


echo "#!/bin/bash" | tee $RESPONSE.sh
echo "#Filename:$RESPONSE.sh" | tee -a $RESPONSE.sh
echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a $RESPONSE.sh


chmod +x $RESPONSE.sh


sudo ln -s ~/Documents/bin/$RESPONSE.sh /usr/local/bin/$RESPONSE.sh


sudo chmod +x /usr/local/bin/$RESPONSE.sh


gedit $RESPONSE.sh


exit

Save the text file and return to the terminal:


chmod +x ~/Documents/bin/cpcbash.sh

Now, whenever you want to write a bash script, just enter the following command:

cpcbash.sh

And enter a name WITHOUT the .sh suffix.

Enjoy!

No comments:

Post a Comment