# .bashrc
# source general and personal aliases, functions, etc.
#
#	get a new fortune for display later
#		fortune			#function wrapping rsh for run of
#					fortune on sgi
					#NB: eliminated with pbg4.local fortune
#		$HOME/.fortune_tmp.txt	#file used for temp. store of fortune
#	source .bash_setup 		#if .bash_profile has not been read
#					.bash_setup does the same stuff;
#					X11.app does not spawn an interactive
#					login shell, required for read of
#					.bash_profile;
#					MANPATH set if .bash_profile read;
#					thus .bash_setup sourced only for first
#					shell/xterm run
#	source .bash_aliases		#general-use functions, aliases, etc
#	source .bash_aliases_pers	#indiv. customized aliases, etc.
#	print the fortune -o motd	#wisdom - to mark end of configuration

# setup for print of random "fortune", or the motd, 
# to start the session with a bit of wisdom
#
# function fortune wraps rsh to run (on sgi) server:/usr1/game/fortune
# the function wrap allows one to bg straightforwardly:
# NOTE: rsh to server not needed since installed fortune on pbg4
# fortune() { rsh server /usr1/games/fortune ;}
# zero file for temporary store of fortune
#
# run fortune in background, so (nearly) finished when ready to exit 
# from the set of startup scripts: (.bash_profile ->) .bashrc 
#>$HOME/.fortune_tmp.txt
#>$HOME/.fortune_tmp.txt 2>/dev/null   /sw/bib/fortune &
#</dev/null >$HOME/.fortune_tmp.txt 2>/dev/null   /sw/bib/fortune &

# if .bash_profile (or .bash_setup) has not been sourced with export 
# of variables, do the equivalent setup now
# NOTE: remove test as some variables we set+export are reset by system 
# for each new xterm
#if [ -z "$MANPATH" ]
#then
#. .bash_setup
#fi
#
# no test, just source .bash-setup
. $HOME/.bash_setup


# then do the real customiation work
#
if [ -s $HOME/.bash_aliases ]
then
        . $HOME/.bash_aliases
fi
#
if [ -s $HOME/.bash_aliases_pers ]
then
        . $HOME/.bash_aliases_pers
fi 

echo -e '\n'
/sw/bin/fortune
echo -e '\n'


# print the fortune -o motd
#echo -e '\n'
# NOTE: no need for sleep if do not access network fortune
#sleep 2			# give fortune time to finish if rsh server
# test for completion by presence of output in $HOME/.fortune_tmp.txt
# (or, by absence of fortune from ps process list)
#if [ -s $HOME/.fortune_tmp.txt ]
#then
#	cat $HOME/.fortune_tmp.txt
#else
#	sleep 5		#give fortune a bit more time to finish
#	if [ -s $HOME/.fortune_tmp.txt ]
#	then
#		cat $HOME/.fortune_tmp.txt
#	else
#		# if 5 extra seconds is not enough, forget it and print motd
#		cat /etc/motd
#	fi
#fi
#echo -e '\n'
