#! /bin/ksh
# environment
#
# STANDARD ENVIRONMENT FILE FOR CLEARCASE
########################################################################
########################################################################
# STANDARD FUNCTIONS
#
# These are various functions that I use for my standard installation.
#
#-----------------------------------------------------------------------
#
# settitle
: Sets the title of DtTerm and XTerm windows.
# setprompt: Sets the prompt to show view, project, directory.
# cd: Sets the prompt and title bar on cd changes.
# setview: Runs "ClearStart" if no view name is given.
# Otherwise, runs "cleartool setview"
# su: Sets the Titlebar on "su" command
# rlogin: Sets the Titlebar on "rlogin" command.
#
#-----------------------------------------------------------------------
#
#
# ####FUNCTION: settitle
#
settitle()
{
[ "$TERM" != "xterm" -a "$TERM" != "dtterm" -a $TERM != "vt100" ] && return
[ -o interactive ] && print "]0;${1}\007"
}
#
# ####FUNCTION: setprompt
#
_setprompt ()
{
[ -x $cleartool ] && \
viewname="$(cleartool pwv -set -short 2> /dev/null)"
[ "** NONE **" = "$viewname" ] && viewname=""
[ "" != "$viewname" ] && viewname="[${viewname}]:"
dir="${PWD#$HOME}"
if [ "" = "$dir" ]
then
dir="~${LOGNAME}"
elif [ "x.$dir" != "x.$PWD" ]
then
dir="~${dir}"
fi
typeset -u prompt=$CCENV_PROJ
export PS1="
${BOLD}${prompt}:${viewname}${dir}
\$${OBOLD} "
}
#
# ####FUNCTION: cd
#
_cd()
{
\cd "$@"
_setprompt
}
alias cd="_cd"
#
# ####Set the Prompt and Titlebar
#
settitle $id@${HOSTNAME}
_setprompt
#
# ####Setview Function: If no parameter specified, sets view
#
setview()
{
if [ "" = "$1" ]
then
clearstart
else
$cleartool setview $1
fi
}
#
# ####Redefine su and rlogin Commands
#
function _rlogin
{
settitle ${id}@${1}
\rlogin "$@"
settitle ${id}@${HOSTNAME}
}
alias rlogin=_rlogin
function _su
{
settitle $1@${HOSTNAME}
\su "$@"
settitle ${id}@${HOSTNAME}
}
alias su=_su
#
########################################################################
########################################################################
# GET RID OF THESE STINKIN' ALIASES: ESPECIALLY THE RM
#
# Our standard environment here has a ton of aliases that glop up
# the works something awful. I have to unalias them or else they
# break all of my shell scripts. This type of stuff should never be
# setup as part of a "standard user environment".
#
unalias c
unalias d
unalias f
unalias fl
unalias flu
unalias j
unalias lk
unalias ll
unalias llk
unalias lll
unalias m
unalias moer #Nope This isn't a mistake!
unalias mroe #Nope This isn't a mistake!
unalias rm
#
########################################################################
########################################################################
# SET KORNSHELL OPTIONS
#
# These shouldn't be here either since it should be up to the
# individual user to set them. However, most of the people here
# use C Shell so these don't get set. I do re-read in the user's
# $ENV though so the user can reset these to their prefered values.
#
set -o allexport
set -o vi
set -o viraw
set -o nolog
#
########################################################################
########################################################################
# CLEARCASE ALIASES
#
# Various aliases that I use to make ClearCase a bit easier. Most
# simply remove having to put "cleartool" in front of each command.
# All the standard "ls" and "cat" commands are here (except ct ls).
# I also alias "cleartool" to simply "ct" and also alias the
# "ci", "co", and "unco" commands. People are just too use to them
# because of RCS.
#
alias ct=$cleartool
alias ci="$cleartool ci"
alias co="$cleartool co"
alias unco="$cleartool unco"
alias desc="$cleartool describe"
alias describe="$cleartool describe"
alias edcs="$cleartool edcs"
alias pwv="$cleartool pwv"
alias xdiff="xcleardiff -blank"
alias clearcase_help="$ATRIAHOME/bin/hyperhelp $ATRIAHOME/doc/hlp/ref.hlp"
alias "clearcase_tutor=$ATRIAHOME/bin/hyperhelp $ATRIAHOME/doc/hlp/tut01.hlp &"
alias catcs="$cleartool catcs"
alias catcr="$cleartool catcr"
alias lsclients="$cleartool lsclients"
alias lsco="$cleartool lscheckout"
alias lsco="$cleartool lsco"
alias lsdo="$cleartool lsdo"
alias lshist="$cleartool lshistory"
alias lslock="$cleartool lslock"
alias lsp="$cleartool lsprivate"
alias lspool="$cleartool lspool"
alias lsprivate="$cleartool lsprivate"
alias lstype="$cleartool lstype"
alias lsview="$cleartool lsview"
alias lsvob="$cleartool lsvob"
alias lsvtree="$cleartool lsvtree"
#
#
########################################################################
########################################################################
# SET DEBUGGER IF DESIRED
#
# Neat little trick for Kornshell script debugging. If the variable
# DEBUG is set, and a script begins with "#! /bin/ksh", then set -xv
# is set, and each line prints as it is executed. The aliases make
# it easier to set this DEBUG variable. To debug a Kornshell script,
# type in "DEBUG" and run that Kornshell script. To turn off Debug
# Mode, type in UNDEBUG.
#
[ "$KSH_DEBUG" ] && set -xv
alias DEBUG="KSH_DEBUG=1"
alias UNDEBUG="unset KSH_DEBUG"
#
########################################################################
########################################################################
# LOAD OLD USER'S ENVIRONMENT FILE
#
# Reload in user's old Environment file if it exists. In our environment,
# we also must source in this /opt/bin/0LOAD file.
#
[ "" != "$OLDENV" ] && . $OLDENV
[ -f /opt/bin/0LOAD ] && . /opt/bin/0LOAD
#
########################################################################