N.S.F. - New Script File Header Creator

If you are like me, you would like to write a new useful script, but being lazy at heart, you prefer to not do all of the basic work like creating the initial script file, adding in comments about what the script is for and perhaps you can’t remember how to make that script executable.

Well sorry, can’t help with all of that stuff, but what if I write a script to create a header for you and make that new script file executable? Perhaps that will get you off your butt and start you writing useful bash scripts that we can all use and love.

Here is my new script file which I am calling nsf for New Script File. Here is the code you need to create:

#!/bin/bash

#: Title       : nsf - New Script File creator
#: Date Created: Thu Sep 2 12:19:58 CDT 2010
#: Last Edit   : Thu Sep 2 12:19:58 CDT 2010
#: Author      : "J. McDaniel" < jmcdaniel3@austin.rr.com
#: Version     : 1.00
#: Description : Create a new script file with blank header
#: Options     : Name of new script file $1

# Created for openSUSE forums on 9-2-2010

# Place Your Name Here as the script file creator
CREATOR="Your Name Here"

# Place the name of your favorite Script Editor here
EDITOR="kwrite"

# make sure we got file-name as command line argument
if  $# -eq 0 ]
then
        echo
    echo "Command Syntax is: ""$0 file-name"
        echo
    exit 1
fi

TARGET=~/bin/$1

# make sure new script file does not exist
if  -e $TARGET ]
then
        echo
    echo "$TARGET file is already present"
        echo
    exit 1
fi

echo "#!/bin/bash" > $TARGET
echo "" >> $TARGET
echo "#: Title       : "$TARGET >> $TARGET
echo "#: Date Created: "$( date ) >> $TARGET
echo "#: Last Edit   : "$( date ) >> $TARGET
echo "#: Author      : "$CREATOR >> $TARGET
echo "#: Version     : 1.00" >> $TARGET
echo "#: Description : " >> $TARGET
echo "#: Options     : " >> $TARGET
echo "" >> $TARGET
echo "exit 0" >> $TARGET
echo "# End Of Script" >> $TARGET

chmod +x $TARGET

# Your script editor name goes here
$EDITOR $TARGET

exit 0
# End Of Script

Copy and paste this code into the folder /home/yourname/bin as the file nsf using your favorite text editor. Next, run this command to make it executable:

chmod +x ~/bin/nsf

In the script, there are two lines you might want to edit. The first is to use your name as the script file editor. Modify the script line that says:

CREATOR="Your Name Here"

To instead use your name. Second, when you run nsf, your new script file header will be created and the new file will be opened by default using kwrite as your text editor. If you prefer to use something else, modify the following line:

EDITOR="kwrite"

To say what ever text editor that you wish to use. Finally, to use nsf, open up a terminal session (such as konsole) as a normal user and type the command:

nsf scriptname

The following terminal command would create an executable script file called scriptname and once kwrite opens it up, you would see something like the following information which you can then edit as your new script:

#!/bin/bash

#: Title       : /home/james/bin/scriptname
#: Date Created: Thu Sep 2 12:24:58 CDT 2010
#: Last Edit   : Thu Sep 2 12:24:58 CDT 2010
#: Author      : Your Name Here
#: Version     : 1.00
#: Description : 
#: Options     : 

exit 0
# End Of Script

I hope you find my New Script File Header Creator script useful. Please post any comments you might have about this script file presented here today.

Thank You,

On 09/02/10 20:06, jdmcdaniel3 wrote:
>
> If you are like me, you would like to write a new useful script, but
> being lazy at heart, you prefer to not do all of the basic work like
> creating the initial script file, adding in comments about what the
> script is for and perhaps you can’t remember how to make that script
> executable.
>
> Well sorry, can’t help with all of that stuff, but what if I write a
> script to create a header for you and make that new script file
> executable? Perhaps that will get you off your butt and start you
> writing useful bash scripts that we can all use and love.
>
> Here is my new script file which I am calling nsf for New Script File.
> Here is the code you need to create:
…]

There is an even simpler method, at least when you’re used to VI(M).
VI has it’s own powerful macro language, that can be used for these and other tasks.
Have a look here:
<http://www.thegeekstuff.com/2009/02/make-vim-as-your-bash-ide-using-bash-support-plugin>

Start VI with a filename called <something>.sh and it will automagically insert all the
relevant header stuff and put you in a BASH edit mode.

Theo

Thanks for your reply LittleRedRooster and the link for anyone that uses vi will find this very useful indeed. While I learned how to use vi, I seldom use it unless I am stuck in the text only world for some reason and so much prefer a program like kwrite. None the less, your post and information is very helpful.

Thank You,

It is time for an update to NSF. I have changed nsf so that it will ask for a new script file name on the desktop using a GUI window, so there is no need to open up a terminal session. If you enter the name of an existing file, you will be asked if you want to edit it, again using a GUI window on the desktop. You can still start nsf with an optional name of the new or now, existing script file name in a terminal window.

To create nsf, copy and past the text in the following code block into your favorite text editor and save the file as nsf in your home area bin folder (~/bin/nsf).

#!/bin/bash

#: Title       : nsf - New Script File creator
#: Date Created: Thu Sep 2 12:19:58 CDT 2010
#: Last Edit   : Thu Oct 14 06:25:00 CDT 2010
#: Author      : "J. McDaniel" < jmcdaniel3@austin.rr.com
#: Version     : 2.00
#: Description : Create a new script file with blank header in your ~/bin folder
#: Options     : Name of new script file $1, now optional

# Created for openSUSE forums on October 14, 2010

# Copy and paste this text into a file in your home area bin folder as nsf (~/bin/nsf)
# To make this script file executable, run the following terminal command: chmod +x ~/bin/nsf

#
# Place Your Name Here as the script file author
#

AUTHOR="Your_Name_Goes_Here"

#
# Place the name of your favorite Script Editor here
#

EDITOR="kwrite"

#
# Location For Your Script Files to be saved
#

FOLD=~/bin


#
# Check for File Name & Ask for one if not present
#

if  $# -eq 0 ] ; then
  FNAME=$(zenity --title "New Script File 2.00" --entry --text "Enter the file name for your new script file:")
  TARGET=$FOLD"/"$FNAME
else
  TARGET=$FOLD"/"$1
fi

#
# Check for Existance of New File, Ask to just edit existing file
#

if  -e $TARGET ] ; then
  zenity --title "Script File Already Exists!" --question --text "Do you wish to Edit this Existing File?"
  rc=$?
  if  "${rc}" == "0" ]; then
    $EDITOR $TARGET
    exit 0
  else
    exit 1
  fi
fi

echo "#!/bin/bash" > $TARGET
echo "" >> $TARGET
echo "#: Title       : "$TARGET >> $TARGET
echo "#: Date Created: "$( date ) >> $TARGET
echo "#: Last Edit   : "$( date ) >> $TARGET
echo "#: Author      : "$AUTHOR >> $TARGET
echo "#: Version     : 1.00" >> $TARGET
echo "#: Description : " >> $TARGET
echo "#: Options     : " >> $TARGET
echo "" >> $TARGET
echo "exit 0" >> $TARGET
echo "# End Of Script" >> $TARGET

chmod +x $TARGET

# Your script editor name goes here
$EDITOR $TARGET

exit 0
# End Of Script

Once saved, open up a terminal session and run the following command:

chmod +x ~/bin/nsf

To use nsf, you can open a terminal session and type nsf or now, why not create a desktop icon instead. Follow these instructions. Copy and past the text in the following code block into your favorite text editor and save it as the file nsf.desktop in your Desktop folder (~/Desktop/nsf.desktop):


[Desktop Entry]
Comment[en_US]=
Comment=
Exec=~/bin/nsf
GenericName[en_US]=New Script File
GenericName=New Script File
Icon=yast-scripts
MimeType=
Name[en_US]=NSF
Name=NSF
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=
X-SuSE-translate=true

Once saved, a new icon should show up on your desktop. Just click the icon, enter the name of your new script file in the GUI window and away you go.

NSF creates a new text script file with a built in header that fills a lot of information for you, using your Favorite text editor and then marks the script file executable for you when you save and close the script file.

Thank You,

Why not make this part of the script?

chmod +x $TARGET

Hello GeoBaltz. I think you may have missed something here. nsf, which stands for New Script File is a script file its self. Before you can use nsf to make new script files for you and automatically make them executable, the nsf script must be made executable. It is the the old chicken and the egg story. I can’t make a new script file mark its self executable until it is well… Executable. Once it is executable, nsf will happily mark all other scripts that you create, executable for you automatically, as if by magic. You just got to make that first move your self.

Thank You,

Doh! Faceslap!

I don’t get the point. Why should I use a script which creates a script header? Just use vi and you’re done …

f

ramp I don’t get the point. Why should I use a script which creates a script header? Just use vi and you’re done …
So everyone has their own ways of doing things but, this created a header for you, including a creation date, it added your name as the author, used your favorite editor and when saved, it marked the script executable AND it places it in the ~/bin folder all for you automatically. The most recent script will pop up a GUI window, asking for the name AND if you put in an existing name, it opens it with your selected editor.

It is designed to save time, enforce some rules on script documentation and puts them all in your selected folder. It is hoped it makes you want to write more script files that do something useful and share them with us all.

Have you written and posted your most useful openSUSE script yet?

Thank You,

Yes, just go to this page.

I have updated NSF (New Script File) to version 2.5 which has the following features …

  1. NSF assists you in creating a new and or editing an existing bash script file.

  2. NSF uses a GUI question and answer window in your desktop for the file name, no need to open up a terminal session.

  3. NSF asks for the name of the script file you wish to create, but if it already exists, you can just edit the existing file.

  4. Existing bash script files will have a backup file made for you, just in case you need it.

  5. Your new script file will receive a header and footer, which you can modify in NSF.

  6. Your new script file will be marked Executable for you.

  7. As you save your bash script file, you do not need to close the editor. Just open a Terminal session, type the script file name and see if it works.

  8. Auto Detection of zenity and kdialog made for you which you can override

To create nsf, copy and past the text in the following code block into your favorite text editor and save the file as nsf in your home area bin folder (~/bin/nsf).

#!/bin/bash

#: Title       : nsf - New Script File creator
#: Date Created: Thu Sep 2 12:19:58 CDT 2010
#: Last Edit   : Wed Jun 29 19:38:58 CDT 2011
#: Author      : "J. McDaniel" < jmcdaniel3@austin.rr.com
#: Version     : 2.50
#: Description : Create a new script file with blank header in your ~/bin folder
#: Options     : Name of new script file $1, now optional

# Created for openSUSE forums on Wednesday June 29, 2011

#
# Place Your Name Here as the script file author
#

AUTHOR="Your Name Here"

#
# Place the name of your favorite Script Editor here
#

EDITOR="kwrite"

#
# Location For Your Script Files to be saved
#

FOLDER=~/bin

#
# Determine if you want a backup file made.  Set to false if you do not
#

BACKUP=true

#
# The GPL Statement
#

function show_gpl {
echo
echo "-----------------------------------------------------------------------"
echo "NSF (New Script File) is written to create a script in openSUSE."
echo "Copyright (C) 2011 by James D. McDaniel, jmcdaniel3@austin.rr.com"
echo
echo "This program is free software; you can redistribute it and/or modify"
echo "it under the terms of the GNU General Public License as published by"
echo "the Free Software Foundation; either version 2 of the License, or"
echo "(at your option) any later version."
echo 
echo "This program is distributed in the hope that it will be useful,"
echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
echo "GNU General Public License for more details."
echo 
echo "You should have received a copy of the GNU General Public License"
echo "along with this program; if not, write to the Free Software"
echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"
echo "-----------------------------------------------------------------------"
echo
}

#
# Output Help if requested
#

function help {
    tput clear
    cat << EOFHELP

New Script File 2.50

Your NSF Startup and help options are:

$0 -h --help :to show this help 

OR

$0 [script.file]

The name script.file is optional and will be requested if not supplied. If the
script file already exists, you will be asked if you wish to edit this file.
EOFHELP
show_gpl
exit 0
}

#
# Display Help if requested.  Example from Findgrub
#

case "$1" in
    -h|--help) help ;;
esac

#
# Lets Determine if first zenity (default) or if kdialog is present
#

which zenity
rc1=$?
if  "${rc1}" == "0" ]; then
  Desktop="GNOME"
else
  which kdialog
  rc2=$?
  if  "${rc2}" == "0" ]; then
    Desktop="KDE"
  else
    echo "I did not find either program zenity or kdialog as being present!"
    exit 1
  fi
fi

#
# You may forces the use of kdialog if you wish
#
# Desktop="KDE"

#
# Check for File Name & Ask for one if not present
#

if  $# -eq 0 ] ; then
  if  $Desktop == "GNOME" ] ; then
    FNAME=$(zenity --title "New Script File 2.50" --entry --text "Enter the file name for your new script file:")
    rc=$?
  else
    FNAME=$(kdialog --title "New Script File 2.50" --inputbox "Enter the file name for your new script file:")
    rc=$?
  fi
  if  "${rc}" != "0" ]; then
    exit 1
  fi
  TARGET=$FOLDER"/"$FNAME
else
  TARGET=$FOLDER"/"$1
fi

#
# Check for Existance of New File, Ask to just edit existing file
#

if  -e $TARGET ] ; then
  if  $Desktop == "GNOME" ] ; then
    zenity --title "Script File Already Exists!" --question --text "Do you wish to Edit this Existing File?"
    rc=$?
  else
    kdialog --title "Script File Already Exists!" --yesnocancel "Do you wish to Edit this Existing File?"
    rc=$?
  fi
  if  "${rc}" == "0" ]; then
    if  "$BACKUP" == "true" ] ; then
#
# Create File Extension for Backup File
#
      ext=$(date +%y%m%d.%H%M%S)
      BACK=$TARGET.$ext
#
# Make a Backup Copy of the File Before the File is edited
#
      cp $TARGET "$BACK"
      chmod -x "$BACK"
    fi
    $EDITOR $TARGET
    exit 0
  else
    exit 1
  fi
fi

echo "#!/bin/bash" > $TARGET
echo "" >> $TARGET
echo "#: Title       : "$TARGET >> $TARGET
echo "#: Date Created: "$( date ) >> $TARGET
echo "#: Last Edit   : "$( date ) >> $TARGET
echo "#: Author      : "$AUTHOR >> $TARGET
echo "#: Version     : 1.00" >> $TARGET
echo "#: Description : " >> $TARGET
echo "#: Options     : " >> $TARGET
echo "" >> $TARGET
echo "exit 0" >> $TARGET
echo "# End Of Script" >> $TARGET

chmod +x $TARGET

# Your script editor name goes here
$EDITOR $TARGET

exit 0
# End Of Script

Once saved, open up a terminal session and run the following command:


chmod +x ~/bin/nsf 

In the script, there are two lines you might want to edit. The first is to use your name as the script file editor. Modify the script line that says:

          
CREATOR="Your Name Here" 

To say what ever text editor that you wish to use. Finally, to use nsf, open up a terminal session (such as konsole) as a normal user and type the command:

          
nsf scriptname 

The following terminal command would create an executable script file called scriptname and once kwrite opens it up, you would see something like the following information which you can then edit as your new script:

#!/bin/bash

#: Title       : /home/james/bin/filename
#: Date Created: Wed Jun 29 20:26:43 CDT 2011
#: Last Edit   : Wed Jun 29 20:26:43 CDT 2011
#: Author      : Your Name
#: Version     : 1.00
#: Description : 
#: Options     : 

exit 0
# End Of Script

I hope you find my New Script File Header Creator script useful. Please post any comments you might have about this script file presented here today.

Thank You,

Hi James,

Maybe you can borrow some functions from this script dialog boxes in bash scripts if you remember it.

I always copy/paste the first header you wrote for findgrub … and forget to change the date. lol!

Hi James,

Maybe you can borrow some functions from this script dialog boxes in bash scripts if you remember it.

I always copy/paste the first header you wrote for findgrub … and forget to change the date. lol!

Hello please_try_again. I will go back and look at that message. I see that is was not even all that long ago, but I did not remember about it. I have decided to go back through some of the old scripts I still use and update them when they were not designed to work with more than one desktop and to add the gpl statement. I might even decide to add that to NSF auto created script as well.

Thank You,

It was actually designed to serve as a ‘library’, providing a set of functions that could be used by other bash scripts to display messages (error,info warning) or dialog boxes (file open/save and entry boxes) in GTK, QT or ncurses depending on the desktop or terminal session used. Users can also enforce GTK dialogs in KDE or QT dialogs in Gnome by exporting the DIALOG environment variable. Here’s a simple example, assuming you have popup in /usr/local/bin:

sample script ~/bin/hello:

#! /bin/bash
source /usr/local/bin/popup 
warn "Hello, you are using $DIALOG dialogs"

Then try:

export DIALOG=KDIALOG && hello
export DIALOG=ZENITY && hello
export DIALOG=DIALOG && hello

I have updated N.S.F. - New Script File to version 2.60 which now adds an option to add a GPL statement to your script file. If you like to share your scripts with others, you may want to think about including a GPL statement. It makes it clear that there is no warranty included with your script even as anyone is free to use and modify your script as they so desire. You still maintain a copyright on your original work, should that be required for something in the future.

NSF (New Script File) version 2.6 has the following features …

  1. NSF assists you in creating a new and or editing an existing bash script file.

  2. NSF uses a GUI question and answer window in your desktop for the file name, no need to open up a terminal session.

  3. NSF asks for the name of the script file you wish to create, but if it already exists, you can just edit the existing file.

  4. Existing bash script files will have a backup file made for you, just in case you need it.

  5. Your new script file will receive a header and footer, which you can modify in NSF.

  6. Your new script file will be marked Executable for you.

  7. As you save your bash script file, you do not need to close the editor. Just open a Terminal session, type the script file name and see if it works.

  8. Auto Detection of zenity and kdialog made for you which you can override.

  9. Allows the addition of a GPL statement to make clear the use of your script should it be released to the public.

  10. Here is the Script File GUI Name Request:

http://thumbnails12.imagebam.com/14047/88f2b6140464202.jpg](http://www.imagebam.com/image/88f2b6140464202)

  1. Here is the GPL GUI statement inclusion request:

http://thumbnails30.imagebam.com/14047/5860f5140464198.jpg](http://www.imagebam.com/image/5860f5140464198)

  1. Should the script file already exist, here is the GUI request to edit anyway:

http://thumbnails44.imagebam.com/14047/de1cdf140464201.jpg](http://www.imagebam.com/image/de1cdf140464201)

To create nsf, copy and past the text in the following code block into your favorite text editor and save the file as nsf in your home area bin folder (~/bin/nsf).

#!/bin/bash

#: Title       : nsf - New Script File creator
#: Date Created: Thu Sep 2 12:19:58 CDT 2010
#: Last Edit   : Wed Jul 13 17:08:58 CDT 2011
#: Author      : J. McDaniel < jmcdaniel3@austin.rr.com
#: Version     : 2.60
#: Description : Create a new script file with blank header in your ~/bin folder
#: Options     : Name of new script file $1, now optional

#
# Created for openSUSE forums on Wednesday July 13, 2011
#

TITLE="N.F.S. - New Script File creator - Version 2.60"

#
# Copy and Paste the text of this script into a text editor and save 
# it as the file nsf in the /home area bin folder 
# example is: /home/username/bin, also known as ~/bin
# This script must be marked executable to be used.  Please  
# run the following Terminal command: chmod +x ~/bin/nsf
# nfs was designed to be run from inside your desktop.
#

#
# Place Your Name Here as the script file author
#

AUTHOR="You Name Here"

#
# Place Your Email Address Here
#

email="your.email@address.com"

#
# Place the name of your favorite Script Editor here
#

EDITOR="kwrite"

#
# Location For Your Script Files to be saved
#

FOLDER=~/bin

#
# Determine if you want a backup file made for existing scripts.  
# Just set to false if you do not want this backup file made.
#

BACKUP=true

#
# The GPL Statement
#

function show_gpl {
echo
echo "-----------------------------------------------------------------------"
echo "NSF (New Script File) is written to create a script in openSUSE."
echo "Copyright (C) 2011 by James D. McDaniel, jmcdaniel3@austin.rr.com"
echo
echo "This program is free software; you can redistribute it and/or modify"
echo "it under the terms of the GNU General Public License as published by"
echo "the Free Software Foundation; either version 2 of the License, or"
echo "(at your option) any later version."
echo 
echo "This program is distributed in the hope that it will be useful,"
echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
echo "GNU General Public License for more details."
echo 
echo "You should have received a copy of the GNU General Public License"
echo "along with this program; if not, write to the Free Software"
echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"
echo "-----------------------------------------------------------------------"
echo
}

#
# The Help which is Displayed
#

function help {
    tput clear
    cat << EOFHELP

$TITLE

Your NSF Startup and help options are:

$(basename $0) -h --help :to show this help 

OR

$(basename $0) [script.file]

The name script.file is optional and will be requested if not supplied. If the
script file already exists, you will be asked if you wish to edit this file.
EOFHELP
show_gpl
exit 0
}

#
# Display Help if requested. 
#

case "$1" in
    -h|--help) help ;;
esac

#
# Lets Determine if first zenity (default) or if kdialog is present
#

which zenity
rc1=$?
if  "${rc1}" == "0" ]; then
  Desktop="GNOME"
else
  which kdialog
  rc2=$?
  if  "${rc2}" == "0" ]; then
    Desktop="KDE"
  else
    echo "I did not find either program zenity or kdialog as being present!"
    exit 1
  fi
fi

#
# You may force the use of kdialog if you wish
#
# Desktop="KDE"

#
# Check for File Name & Ask for one if not present
#

if  $# -eq 0 ] ; then
  if  $Desktop == "GNOME" ] ; then
    FNAME=$(zenity --title "$TITLE" --entry --text "Please enter the file name for your new (or existing) bash script file:")
    rc=$?
  else
    FNAME=$(kdialog --title "$TITLE" --inputbox "Please enter the file name for your new (or existing) bash script file:")
    rc=$?
  fi
  if  "${rc}" != "0" ]; then
    exit 1
  fi
  TARGET=$FOLDER"/"$FNAME
else
  TARGET=$FOLDER"/"$1
fi

#
# Check for Existance of New File, Ask to just edit existing file
#

if  -e $TARGET ] ; then
  if  $Desktop == "GNOME" ] ; then
    zenity --title "The Script File <$(basename $TARGET)> Already Exists!" --question --text "Do you really wish to Edit this Existing Bash Script File?"
    rc=$?
  else
    kdialog --title "The Script File <$(basename $TARGET)> Already Exists!" --yesnocancel "Do you really wish to Edit this Existing Bash Script File?"
    rc=$?
  fi
  if  "${rc}" == "0" ]; then
    if  "$BACKUP" == "true" ] ; then
#
# Create File Extension for Backup File
#
      ext=$(date +%y%m%d.%H%M%S)
      BACK=$TARGET.$ext
#
# Make a Backup Copy of the File Before the File is edited
#
      cp $TARGET "$BACK"
      chmod -x "$BACK"
    fi
    $EDITOR $TARGET
    exit 0
  else
    exit 1
  fi
fi

#
# When we get to here, we are creating an all new bash script file
#

echo "#!/bin/bash" > $TARGET
echo "" >> $TARGET
echo "#: Title       : "$(basename $TARGET) >> $TARGET
echo "#: Date Created: "$( date ) >> $TARGET
echo "#: Last Edit   : "$( date ) >> $TARGET
echo "#: Author      : "$AUTHOR >> $TARGET
echo "#: Version     : 1.00" >> $TARGET
echo "#: Description : " >> $TARGET
echo "#: Options     : " >> $TARGET

if  $Desktop == "GNOME" ] ; then
  zenity --title "GPL Function Statement Request?" --question --text "Do you wish to include a GPL Statement in your script?"
  rc=$?
else
  kdialog --title "GPL Function Statement Request?" --yesnocancel "Do you wish to include a GPL Statement in your script?"
  rc=$?
fi

if  "${rc}" == "0" ]; then

#
# Place GPL Statement into new script file
#

  echo "" >> $TARGET
  strng='#' && echo $strng >> $TARGET
  strng='# This is the standard GPL Statement, leave at the top of the script.' && echo $strng >> $TARGET
  strng='# Just use the command show_gpl after this function for it to be shown.' && echo $strng >> $TARGET
  strng='#' && echo $strng >> $TARGET
  echo "" >> $TARGET
  strng='function show_gpl { ' && echo $strng >> $TARGET
  strng='echo ""'  && echo $strng >> $TARGET
  strng='echo "'$(basename $TARGET)' is a bash script file written to be used with openSUSE."' && echo $strng >> $TARGET
  strng='echo "Copyright (C) 2011 by '$AUTHOR', '$email'"' && echo $strng >> $TARGET
  strng='echo ""' && echo $strng >> $TARGET
  strng='echo "This program is free software; you can redistribute it and/or modify"' && echo $strng >> $TARGET
  strng='echo "it under the terms of the GNU General Public License as published by"' && echo $strng >> $TARGET
  strng='echo "the Free Software Foundation; either version 2 of the License, or"' && echo $strng >> $TARGET
  strng='echo "(at your option) any later version."' && echo $strng >> $TARGET
  strng='echo ""' && echo $strng >> $TARGET
  strng='echo "This program is distributed in the hope that it will be useful,"' && echo $strng >> $TARGET
  strng='echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"' && echo $strng >> $TARGET
  strng='echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"' && echo $strng >> $TARGET
  strng='echo "GNU General Public License for more details."' && echo $strng >> $TARGET
  strng='echo ""' && echo $strng >> $TARGET
  strng='echo "You should have received a copy of the GNU General Public License"' && echo $strng >> $TARGET
  strng='echo "along with this program; if not, write to the Free Software"' && echo $strng >> $TARGET
  strng='echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"' && echo $strng >> $TARGET
  strng='echo ""'&& echo $strng >> $TARGET
  strng='}' && echo $strng >> $TARGET
fi

echo "" >> $TARGET
echo "" >> $TARGET
echo "" >> $TARGET

echo "exit 0" >> $TARGET
echo "" >> $TARGET
echo "# End Of Script" >> $TARGET

chmod +x $TARGET

# Your script editor name goes here
$EDITOR $TARGET

exit 0
# End Of Script

Once saved, open up a terminal session and run the following command:

chmod +x ~/bin/nsf

In the script, there are three lines you need to edit. The first is your name as the script file author. Next is your email address for the GPL statement and finally the name of the text editor you wist to use. Modify the script lines that say:

AUTHOR="You Name Here"
email="your.email@address.com"
EDITOR="kwrite"

You can create a shortcut on your desktop using the following text. Copy and past this into a text editor and save it as the file nsf.desktop in your /home/username/Desktop folder (~/Desktop/nsf.desktop):

[Desktop Entry]
Comment[en_US]=
Comment=
Exec=~/bin/nsf
GenericName[en_US]=New Script File
GenericName=New Script File
Icon=yast-scripts
MimeType=
Name[en_US]=NSF
Name=NSF
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=
X-SuSE-translate=true

You must open a terminal session and mark the shortcut executable with the following terminal command.

chmod +x ~/Desktop/nsf.desktop

Running the nsf.desktop icon from your desktop would create an executable script file called myscript (in this example) and once kwrite opens it up, you would see something like the following information which you can then edit as your new script:

#!/bin/bash

#: Title       : myscript
#: Date Created: Wed Jul 13 17:54:21 CDT 2011
#: Last Edit   : Wed Jul 13 17:54:21 CDT 2011
#: Author      : Your Name Here
#: Version     : 1.00
#: Description : 
#: Options     : 

#
# This is the standard GPL Statement, leave at the top of the script.
# Just use the command show_gpl after this function for it to be shown.
#

function show_gpl {
echo ""
echo "myscript is a bash script file written to be used with openSUSE."
echo "Copyright (C) 2011 by Your Name Here, your.email@address.com"
echo ""
echo "This program is free software; you can redistribute it and/or modify"
echo "it under the terms of the GNU General Public License as published by"
echo "the Free Software Foundation; either version 2 of the License, or"
echo "(at your option) any later version."
echo ""
echo "This program is distributed in the hope that it will be useful,"
echo "but WITHOUT ANY WARRANTY; without even the implied warranty of"
echo "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
echo "GNU General Public License for more details."
echo ""
echo "You should have received a copy of the GNU General Public License"
echo "along with this program; if not, write to the Free Software"
echo "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"
echo ""
}



exit 0

# End Of Script

As always, I would love to hear any comments you have about using the script file creator script.

Thank You,