# # Default startup file for the Korn shell # # following are variables used by ksh that may be customized # #CDPATH= # search path for 'cd' #COLUMNS=80 # columns on the terminal EDITOR=$(whence vi) # enable command line editing using the vi editor #ENV=$HOME/.kshrc # environment file (see $HOME/.profile) #FCEDIT=ed # editor for 'fc' built-in #FPATH= # search path for auto-load functions #HISTFILE=$HOME/.sh_history # history file #HISTSIZE=128 # number of history commands #HOME=/home/$LOGNAME # home directory #IFS=: # internal field separator #LINES=24 # number of lines on the terminal #MAIL= # name of mail file (set $HOME/.profile) #MAILCHECK=600 # frequency of mail check #MAILPATH= # list of mail files #PATH= # path search directories (see $HOME/.profile) PS1='$PWD # ' # set prompt string to the current directory name #PS2=">" # secondary prompt string #PS3="#?" # select command prompt #PS4="+" # debug prompt string #SHELL=/usr/bin/ksh # pathname of the shell #TERM= # terminal type (see $HOME/.profile) #TMOUT=0 # timeout variable #VISUAL= # override for $EDITOR # # Aliases alias Mail='mailx ' alias mail='mailx ' alias print=/bin/print alias ls='/bin/ls -aF ' alias ll='/bin/ls -Fail ' #alias m='less -mesp' alias m='more' alias j='jobs -l' alias s='fg %-' alias maek=make # # directory stack aliases alias pd='pushd' alias po='popd' alias dirs='prcdstack' alias d='prcdstack' # # Functions # function term { if [ $# -eq 1 ] then echo $TERM TERM=$1 export TERM fi echo $TERM } function display { if [ $# -eq 1 ] then echo $DISPLAY DISPLAY=$1 export DISPLAY fi echo $DISPLAY } # Set up variables needed for pushd/popd integer cdindex let cdindex=${cdindex:=0} BASE=${BASE:=""} # print out the cd stack function prcdstack { # make sure any cd's done by user are updated on the stack cdstack[cdindex]=`pwd` i=$cdindex while (( i>=0 )); do if [ "${cdstack[$i]#$HOME}" != ${cdstack[$i]} ]; then echo "~${cdstack[$i]#$HOME}\c" elif [ "${cdstack[$i]#$BASE}" != ${cdstack[$i]} ]; then echo "\$BASE${cdstack[$i]#$BASE}\c" else echo "${cdstack[$i]}\c" fi if [ $i -gt 0 ]; then # output a space echo " \c" else echo "\n\c" #output a newline fi let i=i-1 done return; } function pushd { if [ $# -gt 1 ]; then echo "pushd: Too many arguments" return 1; fi # make sure any cd's done by user are updated on the stack cdstack[cdindex]=`pwd` if [ $# -eq 0 ]; then # no arg to pushd - swap top 2 dirs if [ cdindex -eq 0 ]; then # not enough dirs to swap echo "No other directory" return 1; fi # else swap top 2 dirs cd ${cdstack[$cdindex-1]} if [ $? -eq 0 ]; then # cd succeeded cdtmp=${cdstack[$cdindex]} cdstack[$cdindex]=${cdstack[$cdindex-1]} cdstack[$cdindex-1]=$cdtmp prcdstack fi else # cd to new dir and push onto stack cd $1 if [ $? -eq 0 ]; then # cd succeeded if [ cdindex -eq 0 ]; then # cdstack is empty cdstack[0]=$OLDPWD cdstack[1]=`pwd` let cdindex=1 else cdstack[cdindex+1]=`pwd` let cdindex=cdindex+1 fi prcdstack fi fi return; } function popd { if [ cdindex -eq 0 ]; then # cdstack is empty echo "popd: Directory stack empty" return 1; fi # make sure any cd's done by user are updated on the stack cdstack[cdindex]=`pwd` cd ${cdstack[$cdindex-1]} if [ $? -eq 0 ]; then # cd succeeded let cdindex=cdindex-1 prcdstack fi }