Skip to content

Instantly share code, notes, and snippets.

@hapylestat
Created August 23, 2013 14:41
Show Gist options
  • Save hapylestat/6320083 to your computer and use it in GitHub Desktop.
Save hapylestat/6320083 to your computer and use it in GitHub Desktop.
[bash-tool] Create new script from template. How to use: - Copy script with template to installdir - Make symlink to /usr/bin or other globaly searchable directory
#!/bin/bash
######################################
# Shell script #
# Author: H.L. #
# TPL Version: 0.1 #
######################################
#========================Global variables
APPVER="0.1b"
MYDIR=`echo $0`
MYREALDIR=`readlink $MYDIR`
if [ ! -z $MYREALDIR ]; then MYDIR=$MYREALDIR; fi;
FILENAME=`echo $MYDIR|rev|cut -d / -f 1|rev`
MYDIR=${MYDIR%%/$FILENAME}
#=======================Include base library
. $MYDIR/functions
# $1 - filename
if [ ! -z $1 ]; then
run "cp -f $MYDIR/template $PWD/$1" "Create script from template"
run "chmod u+x $PWD/$1" "Apply execute permissions"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment