#	$PS1 is unset in a shell script

if [ -z "$PS1" ]
then
	interactive=FALSE
else
	interactive=TRUE
fi

#	make sure that we get command line editing
set -o emacs
#	maintain the hash table of commands
set -o trackall

#	set up my aliases

alias a=alias
a l='ls -l'
a lt='ls -lt'
a la='ls -la'
a h='fc -l'
a which='whence -v'
a vt='vtree -v'
a up=unixpath
#	DOS has such a bad influence :-)
a md=mkdir
a rd=rmdir

export HISTFILE=$HOME/sh_hist
#	Sorry HISTSIZE isn't implemented yet, it default's to 100
#export HISTSIZE=50

typeset PS1='[! $PWD] '

#	TERMCAP variable doesn't work correctly if you use a name that doesn't
#	start with a '/' hence the /dev/d.. stuff instead of d:
#
#	Don't try setting this in the profile.ksh, mgr unset's TERMCAP as well
#	as TERM, as far as I can see this causes more problems than it solves.

export TERMCAP=/dev/d/etc/termcap

#	this bit rather assumes a hi-res startup in 50 line mode

export TERM=${TERM:-atari50}
case $TERM in 
	vt*|at* )
		;;
	mgr )
		ulimit -m 1024		# This works fine on my Mega 4, but may need
							# changing. 1Mb is just enough for gcc.
		a cls="vt52 cls"	# not only does this clear the screen but it resets
							# the screen size to 25 * 80
		;;
esac

#	Added this one - saves typing
CDPATH="d:/usr;d:/usr/work;e:/mint"

#	a bit primitive, but it does the job if you've compressed all your man pages
#	I should install Bill Rosenkranz's man package instead.
export MANDIR=d:/man

function man {
	if [ $# -ne 1 ]
	then
		echo Usage: $0 file
		return 1
	fi

	name=${1%%.ma?}

	for dir in . $MANDIR
	do
		if [ -r $dir/$name.man ]
		then
			less $dir/$name.man
			return
		elif [ -r $dir/$name.maz ]
		then
			compress -dc $dir/$name.maz | less
			return
		fi
	done
}

#	just for testing
a new='exec ~/ksh.tos'

if [ $interactive = "TRUE" ]	# Can't really be bothered to load these on 
then							# a non interactive shell.
	. ~/pushd					# Add functions for dirs, pushd, popd
fi								# Taking this out speeds up scripts quite a bit

unset interactive

typeset -l PWD					# I like pwd's to be lower case

# basename/dirname as shell functions

function basename {
	case $# in
		1)	;;
		2)	eval set \${1%$2} ;;
		*)	echo Usage: $0 pathname '[suffix]'
			return 1;;
	esac
	echo ${1##*[\\/]}
	return 0
}

function dirname {
	if [ $# -ne 1 ]
	then
		echo Usage: $0 pathname
		return 1
	fi
	echo ${1%[\\/]*}
	return 0
}

