[BACK]Return to ksh.kshrc CVS log [TXT][DIR] Up to [local] / src / etc

Annotation of src/etc/ksh.kshrc, Revision 1.10

1.1       downsj      1: :
1.10    ! todd        2: #      $OpenBSD: ksh.kshrc,v 1.9 2002/05/30 06:44:07 deraadt Exp $
1.1       downsj      3: #
                      4: # NAME:
1.8       deraadt     5: #      ksh.kshrc - global initialization for ksh
1.1       downsj      6: #
                      7: # DESCRIPTION:
                      8: #      Each invocation of /bin/ksh processes the file pointed
                      9: #      to by $ENV (usually $HOME/.kshrc).
                     10: #      This file is intended as a global .kshrc file for the
                     11: #      Korn shell.  A user's $HOME/.kshrc file simply requires
                     12: #      the line:
                     13: #              . /etc/ksh.kshrc
                     14: #      at or near the start to pick up the defaults in this
                     15: #      file which can then be overridden as desired.
                     16: #
                     17: # SEE ALSO:
                     18: #      $HOME/.kshrc
                     19: #
                     20:
                     21: # RCSid:
                     22: #      $From: ksh.kshrc,v 1.4 1992/12/05 13:14:48 sjg Exp $
                     23: #
                     24: #      @(#)Copyright (c) 1991 Simon J. Gerraty
                     25: #
                     26: #      This file is provided in the hope that it will
                     27: #      be of use.  There is absolutely NO WARRANTY.
                     28: #      Permission to copy, redistribute or otherwise
1.8       deraadt    29: #      use this file is hereby granted provided that
1.1       downsj     30: #      the above copyright notice and this notice are
1.8       deraadt    31: #      left intact.
1.1       downsj     32:
                     33: case "$-" in
                     34: *i*)   # we are interactive
                     35:        # we may have su'ed so reset these
                     36:        # NOTE: SCO-UNIX doesn't have whoami,
                     37:        #       install whoami.sh
                     38:        USER=`whoami 2>/dev/null`
                     39:         USER=${USER:-`id | sed 's/^[^(]*(\([^)]*\)).*/\1/'`}
1.3       marc       40:        UID=`id -u`
1.1       downsj     41:        case $UID in
                     42:        0) PS1S='# ';;
                     43:        esac
                     44:         PS1S=${PS1S:-'$ '}
                     45:        HOSTNAME=${HOSTNAME:-`uname -n`}
                     46:        HOST=${HOSTNAME%%.*}
                     47:
                     48:        PROMPT="$USER:!$PS1S"
                     49:        #PROMPT="<$USER@$HOST:!>$PS1S"
                     50:        PPROMPT='$USER:$PWD:!'"$PS1S"
                     51:        #PPROMPT='<$USER@$HOST:$PWD:!>'"$PS1S"
                     52:        PS1=$PPROMPT
                     53:        # $TTY is the tty we logged in on,
                     54:        # $tty is that which we are in now (might by pty)
                     55:        tty=`tty`
                     56:        tty=`basename $tty`
                     57:         TTY=${TTY:-$tty}
1.8       deraadt    58:
1.1       downsj     59:        set -o emacs
                     60:
                     61:        alias ls='ls -CF'
                     62:        alias h='fc -l | more'
                     63:        # the PD ksh is not 100% compatible
                     64:        case "$KSH_VERSION" in
                     65:        *PD*)   # PD ksh
                     66:                ;;
                     67:        *)      # real ksh ?
                     68:                [ -r $HOME/.functions ] && . $HOME/.functions
                     69:                set -o trackall
                     70:                ;;
                     71:        esac
                     72:        case "$TERM" in
1.3       marc       73:        sun*-s)
                     74:                # sun console with status line
1.2       kstailey   75:                if [ "$tty" != "$console" ]; then
1.1       downsj     76:                        # ilabel
                     77:                        ILS='\033]L'; ILE='\033\\'
                     78:                        # window title bar
                     79:                        WLS='\033]l'; WLE='\033\\'
                     80:                fi
                     81:                ;;
                     82:        xterm*)
                     83:                ILS='\033]1;'; ILE='\007'
                     84:                WLS='\033]2;'; WLE='\007'
                     85:                 parent="`ps -ax 2>/dev/null | grep $PPID | grep -v grep`"
                     86:                 case "$parent" in
                     87:                *telnet*)
                     88:                   export TERM=xterms;;
                     89:                esac
                     90:                ;;
                     91:        *)      ;;
                     92:        esac
                     93:        # do we want window decorations?
                     94:        if [ "$ILS" ]; then
1.10    ! todd       95:                ilabel () { print -n "${ILS}$*${ILE}">/dev/tty; }
        !            96:                label () { print -n "${WLS}$*${WLE}">/dev/tty; }
1.1       downsj     97:
                     98:                alias stripe='label "$USER@$HOST ($tty) - $PWD"'
                     99:                alias istripe='ilabel "$USER@$HOST ($tty)"'
                    100:
                    101:                wftp () { ilabel "ftp $*"; "ftp" $*; eval istripe; }
1.7       marc      102:                wcd () { \cd "$@" && eval stripe; }
1.6       todd      103:                wssh ()
                    104:                {
                    105:                        "ssh" "$@"
                    106:                        eval istripe
                    107:                        eval stripe
                    108:                }
1.1       downsj    109:                wtelnet ()
                    110:                {
                    111:                        "telnet" "$@"
                    112:                        eval istripe
                    113:                        eval stripe
                    114:                }
                    115:                wrlogin ()
                    116:                {
                    117:                        "rlogin" "$@"
                    118:                        eval istripe
                    119:                        eval stripe
                    120:                }
                    121:                wsu ()
                    122:                {
                    123:                        "su" "$@"
                    124:                        eval istripe
                    125:                        eval stripe
                    126:                }
                    127:                alias su=wsu
                    128:                alias cd=wcd
                    129:                alias ftp=wftp
1.6       todd      130:                alias ssh=wssh
1.1       downsj    131:                alias telnet=wtelnet
                    132:                alias rlogin=wrlogin
                    133:                eval stripe
                    134:                eval istripe
                    135:                PS1=$PROMPT
                    136:        fi
                    137:        alias quit=exit
                    138:        alias cls=clear
                    139:        alias logout=exit
                    140:        alias bye=exit
                    141:        alias p='ps -l'
                    142:        alias j=jobs
                    143:        alias o='fg %-'
                    144:        alias ls='ls -gCF'
                    145:
                    146: # add your favourite aliases here
                    147:        OS=${OS:-`uname -s`}
                    148:        case $OS in
                    149:        HP-UX)
1.9       deraadt   150:                alias ls='ls -CF'
1.1       downsj    151:                 ;;
                    152:        *BSD)
                    153:                alias df='df -k'
                    154:                alias du='du -k'
                    155:                ;;
1.8       deraadt   156:        esac
1.1       downsj    157:        alias rsize='eval `resize`'
                    158:
                    159:        case "$TERM" in
                    160:        sun*|xterm*)
                    161:                case $tty in
1.8       deraadt   162:                tty[p-w]*)
1.1       downsj    163:                        case "$DISPLAY" in
                    164:                        "")
                    165:                                DISPLAY="`who | grep $TTY | sed -n 's/.*(\([^:)]*\)[:)].*/\1/p' | sed 's/\([a-zA-Z][^.]*\).*/\1/'`:0"
                    166:                                ;;
                    167:                        esac
                    168:                        ;;
                    169:                esac
                    170:                case "$DISPLAY" in
                    171:                ozen*|:*)
                    172:                        stty erase "^?"
                    173:                        ;;
                    174:                *)
                    175:                        stty erase "^h"
                    176:                        ;;
                    177:                esac
                    178:                export DISPLAY
                    179:                ;;
                    180:        esac
                    181:
                    182: ;;
                    183: *)     # non-interactive
                    184: ;;
                    185: esac
                    186: # commands for both interactive and non-interactive shells
                    187:
                    188: # is $1 missing from $2 (or PATH) ?
                    189: no_path () {
                    190:   eval _v="\$${2:-PATH}"
                    191:   case :$_v: in
                    192:   *:$1:*) return 1;;           # no we have it
                    193:   esac
                    194:   return 0
                    195: }
                    196: # if $1 exists and is not in path, append it
                    197: add_path () {
                    198:   [ -d ${1:-.} ] && no_path $* && eval ${2:-PATH}="\$${2:-PATH}:$1"
                    199: }
                    200: # if $1 exists and is not in path, prepend it
                    201: pre_path () {
                    202:   [ -d ${1:-.} ] && no_path $* && eval ${2:-PATH}="$1:\$${2:-PATH}"
                    203: }
                    204: # if $1 is in path, remove it
                    205: del_path () {
1.8       deraadt   206:   no_path $* || eval ${2:-PATH}=`eval echo :'$'${2:-PATH}: |
1.1       downsj    207:     sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;"`
                    208: }