Ptouch: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== What is ptouch? == | |||
"I am 12 and what is this?" Ptouch is basically an attempt at saving a few key strokes. The utility is designed to allow a programmer to begin work on an executable script. It will create a file, make it executable and add your interpreter specified at the command line. If you do not specify an interpreter, PERL is assumed by this | |||
== Usage == | |||
ptouch code_file [interpreter] | |||
== Installation == | |||
You can do this in a couple of ways. If you would like the script to be installed for all users on a system do the following: | |||
wget -O /usr/local/bin/ptouch http://henge.cavemantech.net/source/utilities/ptouch/ptouch | |||
chmod 755 /usr/local/bin/ptouch | |||
Alternatively, if you wish to install for only the currently logged in user: | |||
mkdir ~/bin | |||
wget -O ~/bin/ptouch http://henge.cavemantech.net/source/utilities/ptouch/ptouch | |||
chmod u+x ~/bin/ptouch | |||
echo "export PATH=$PATH:~/bin" >> ~/.bashrc | |||
== The code == | |||
Line 7: | Line 35: | ||
#**************************# | #**************************# | ||
# Name: ptouch # | # Name: ptouch # | ||
# Version: 1. | # Version: 1.1 # | ||
# Author: Kevin M. Johsnon # | # Author: Kevin M. Johsnon # | ||
#**************************# | #**************************# | ||
#-------------#--------------------------------------------# | #-------------#--------------------------------------------#---------# | ||
# Change Log | | | # Change Log | | | | ||
#-------------#--------------------------------------------# | #-------------#--------------------------------------------#---------# | ||
# Date # Change Description | | # Date # Change Description | Version | | ||
#-------------#--------------------------------------------# | #-------------#--------------------------------------------#---------# | ||
# 2011-05-21 | Original utility creation. | | # 2011-05-21 | Original utility creation. | 1.0 | | ||
#-------------#--------------------------------------------# | #-------------#--------------------------------------------#---------# | ||
# 2011-05-31 | Added support for second interpreter arg. | 1.1 | | |||
#-------------#--------------------------------------------#---------# | |||
if [ -e $1 ] | if [ -e $1 ] | ||
Line 27: | Line 57: | ||
fi | fi | ||
if [ "$2" != "" ] | |||
then | |||
interpreter=`which $2`; | |||
else | |||
interpreter=`which perl`; | |||
fi | |||
echo "#!$ | echo "#!$interpreter" > $1; | ||
chmod u+x $1; | chmod u+x $1; | ||
vim $1; | vim $1; | ||
</pre> | </pre> |
Revision as of 20:43, 31 May 2011
What is ptouch?
"I am 12 and what is this?" Ptouch is basically an attempt at saving a few key strokes. The utility is designed to allow a programmer to begin work on an executable script. It will create a file, make it executable and add your interpreter specified at the command line. If you do not specify an interpreter, PERL is assumed by this
Usage
ptouch code_file [interpreter]
Installation
You can do this in a couple of ways. If you would like the script to be installed for all users on a system do the following:
wget -O /usr/local/bin/ptouch http://henge.cavemantech.net/source/utilities/ptouch/ptouch chmod 755 /usr/local/bin/ptouch
Alternatively, if you wish to install for only the currently logged in user:
mkdir ~/bin wget -O ~/bin/ptouch http://henge.cavemantech.net/source/utilities/ptouch/ptouch chmod u+x ~/bin/ptouch echo "export PATH=$PATH:~/bin" >> ~/.bashrc
The code
#!/bin/bash #**************************# # Name: ptouch # # Version: 1.1 # # Author: Kevin M. Johsnon # #**************************# #-------------#--------------------------------------------#---------# # Change Log | | | #-------------#--------------------------------------------#---------# # Date # Change Description | Version | #-------------#--------------------------------------------#---------# # 2011-05-21 | Original utility creation. | 1.0 | #-------------#--------------------------------------------#---------# # 2011-05-31 | Added support for second interpreter arg. | 1.1 | #-------------#--------------------------------------------#---------# if [ -e $1 ] then echo "The file $1 already exists. Launching vim." ; sleep 2; vim $1; exit; fi if [ "$2" != "" ] then interpreter=`which $2`; else interpreter=`which perl`; fi echo "#!$interpreter" > $1; chmod u+x $1; vim $1;