#!/bin/bash	
#v kutz v. 1.0 by duus        (Mar 21, 2011)
#v   location: http://thedu.us/scripts/kutz/kutz
#h kutz, kutz FILE adds text from CLIPBOARD to kutz-FILENAME, v 0.1, by duus
##################################################### VERSION INFO
#v kutz, kutz FILE adds text from CLIPBOARD to kutz-FILENAME, v 0.1, by duus
#v
#v 	  type <kutz help> for more information
#v    or open source code with a text editor and read it:
#v    http://thedu.us/scripts/kutz/kutz/
#v
###################################################### INSTALL INFO
#i How to install kutz
#i  1. put the kutz bash script on your path (for example, ~/bin/)
#i  2. navigate to that directory
#i  3. type "chmod +x kutz" to make the script executable
#i  4. open the kutz script with your favorite text editor (pico kutz, for example)
#i  5. Navigate to the line called #SETTINGS
#i  6. Adjust settings as necessary.  Save the file.
#i  7. type "kutz help" for usage information
#i
###################################################### SETTINGS
# general settings; name and location of this script, for self-referencing.
_SCRIPT_NAME=kutz            
_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 kutz   (Mar 21, 2011)
# --------------------------
if [ "$1" = "" ]
	then
   $_SCRIPT_LOCATION/${_SCRIPT_NAME} help
	exit 1;
fi
#h usage: kutz FILENAME (append)-- appends to file kutz-FILENAME
#h usage: kutz FILENAME more -- mores the kutz-FILENAME doc
_file="$1"
_kutzfile="kutz-$1"
if [ "$2" = "" ]
	then
		_cmd="append"
	else
		_cmd="$2"
	fi
if [ "_cmd" = "more" ]
	then
	more ${_kutzfile}
fi
if [ "_cmd" = "append" ]
	then
		echo "append CLIPBOARD to ${_kutzfile}"
		echo " kutz (`date`):" >> ${_kutzfile}
		pbpaste >> ${_kutzfile}
		echo "">> ${_kutzfile}		
fi
#h  <help>, <version>, <install>, <src> 
#h    give help, version, install information, and source code, respectively
# --------------------------
# <tt>                 :               end kutz
#                      . 
#            ...---.,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/kutz/kutz 
# </tt>                .    Last invoked: Mar 21, 2011, when duus was feeling indignant.
# -------------------------- 

