#!/bin/sh	
#v term v. 1.0 by duus        (Mar 05, 2008)
#v   location: http://thedu.us/scripts/THISSIR/term
#h term script by duus

##################################################### VERSION INFO
#v term, runs term libraries, v 0.1, by duus
#v
#v 	  type <term help> for more information
#v    or open source code with a text editor and read it:
#v    http://thedu.us/scripts/system/term/
#v
###################################################### INSTALL INFO
#i How to install term
#i  1. put the term bash script on your path (for example, ~/bin/)
#i  2. navigate to that directory
#i  3. type "chmod +x term" to make the script executable
#i  4. open the term script with your favorite text editor (pico term, for example)
#i  5. Navigate to the line called #SETTINGS
#i  6. Adjust settings as necessary.  Save the file.
#i  7. type "term help" for usage information
#i
###################################################### SETTINGS
# general settings; name and location of this script, for self-referencing.
_SCRIPT_NAME=term            
_SCRIPT_LOCATION=~/bin           
# you can also hardcode if you would like.  For example, your own bin:
# _SCRIPT_LOCATION=~/bin
# or, if you are running reuben, you can access reuben's bin:
# _SCRIPT_LOCATION=~/.reuben/.bin/
# don't forget that this program is merely a text file, and you must make 
#   it executable, regardless of where you place it.
# Script_Location is used in the standard functions, below.
#
###################################################### STD, FUNCTIONS (help, version, install)
#  (h)elp, (v)ersion, and (i)nstall are standard.  I do not recommend changing them.
#    Reading them, on the other hand, to see how they work is encouraged.
#    Feel free to add another standard function.  If you do, please let me know if it is useful,
#     and whether you would mind if I included it in the standard code, with credit for you
#     in comments.  (Or an about section?  .... hmmmm)
#    These functions allow the output of the standard functions to be 
#    hardcoded into the source code.  (See #i and #v above for examples.) 
#
if [ "$1" = "version" -o "$1" = "v" ]                
	then   
	grep "^#v" $_SCRIPT_LOCATION/${_SCRIPT_NAME} | more                              
	exit 1;
elif [ "$1" = "help" -o "$1" = "h" ]
	then
	grep "^#h" $_SCRIPT_LOCATION/${_SCRIPT_NAME} | more
	exit 1;
elif [ "$1" = "install" -o "$1" = "i" ]
	then
	grep "^#i" $_SCRIPT_LOCATION/${_SCRIPT_NAME} | more
	exit 1;
elif [ "$1" = "src" ]
	then
	echo "source code of ${_SCRIPT_NAME}, a duusscript"
	echo ""
	more $_SCRIPT_LOCATION/${_SCRIPT_NAME}
	exit 1;
fi 
#
#  don't understand how this works?  see http://thedu.us/scripts/duushelp/ or run duushelp.sh
#
################################################################
#---------------------------------------------------------#
# begin term   (Mar 05, 2008)
# --------------------------
_termlib=`sdoc`/Software/terminal/
_indiv=terms/
_groups=windowgroups/
#h   (g)roup NAME: opens terminal group NAME
#h   NAME: opens terminal window NAME
#h   NUM: opens terminal window group special, num
#h   spaces: opens the terminal windows associated with spaces
if [ "$1" = "spaces" ]
	then 
	echo "open the terminal windows by spaces"
	space 2
	term 2
	space 3
	term 3
	space 4
	term 4
	space 6
	term 6
	echo "done."
	exit 1;
fi
#
_tf=$1
if [ `isnumeric $_tf` = 1 ]
	then 
		case "$_tf" in
		'2')
			_tf='duus Space 2: Tan'
			;;
		'3')
			_tf='duus Space 3: Blue'
			;;
		'4')
			_tf='duus Space 4: Dandelion'
			;;
		'6')
			_tf='duus Space 6: White'
			;;
		*)
			echo "num ${_tf} unknown, exiting."
			;;
		esac
		cd ${_termlib}${_groups}
		_file="${_tf}.terminal"
elif [ "$_tf" = "group" -o  "$_tf" = "g" ]
	then
	cd ${_termlib}${_groups}
	_tf=${2}
	_file="${_tf}.terminal"
	else
	cd ${_termlib}${_indiv}
	_file="${_tf}.terminal"
fi

if [ -f "${_file}" ]
	then
	echo "open ${_file}..."
	open "${_file}"
	else
	echo "${_file} does not exist.  Did you export it properly?"
	echo "open page in firefox? [N/y]"
	read yesno
	if [ "${yesno}" = "y" -o "${yesno}" = "yes" ]
		then
		firesite "http://books.google.com/books?id=GYP7MAxi_oMC&pg=PA635&lpg=PA635&dq=osx+terminal++%22window+group%22&source=web&ots=WfsVmidhg9&sig=PJn-9PfFO8UEAAdaKslYCQm6n1Y&hl=en&sa=X&oi=book_result&resnum=1&ct=result"
	fi
fi
# --------------------------
# <tt>                 :               end term
#                      . 
#            ...---.,o8:i__,8Pd8   
#         _//      `"' :  d8'",8d8   
#       ,/''  vVv      . dP   b8P.8|
#      ./;|  d^_^b     .     ,P O||]
#       |||  duus@thedu.us\     |||| 
#       |||  duus.thedu.us/      || 
#       ||\            .        /_' 
#        ;+,           :       |\8
#          '.`>+.     _./'_/2/b/_
#           '-oh\._.._j:;'`P;8/,
#              `'->:o:.:src/='
#                      :    
#                      :    http://thedu.us/scripts/system/term 
# </tt>                .    Last invoked: Mar 05, 2008, when duus was feeling contemplative.
# -------------------------- 

