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

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

1.32    ! mpf         1: #      $OpenBSD: ksh.kshrc,v 1.31 2018/02/18 21:48:00 kn Exp $
1.1       downsj      2: #
                      3: # NAME:
1.8       deraadt     4: #      ksh.kshrc - global initialization for ksh
1.1       downsj      5: #
                      6: # DESCRIPTION:
                      7: #      Each invocation of /bin/ksh processes the file pointed
                      8: #      to by $ENV (usually $HOME/.kshrc).
                      9: #      This file is intended as a global .kshrc file for the
                     10: #      Korn shell.  A user's $HOME/.kshrc file simply requires
                     11: #      the line:
                     12: #              . /etc/ksh.kshrc
                     13: #      at or near the start to pick up the defaults in this
                     14: #      file which can then be overridden as desired.
                     15: #
                     16: # SEE ALSO:
                     17: #      $HOME/.kshrc
                     18: #
                     19:
                     20: # RCSid:
                     21: #      $From: ksh.kshrc,v 1.4 1992/12/05 13:14:48 sjg Exp $
                     22: #
                     23: #      @(#)Copyright (c) 1991 Simon J. Gerraty
                     24: #
                     25: #      This file is provided in the hope that it will
                     26: #      be of use.  There is absolutely NO WARRANTY.
                     27: #      Permission to copy, redistribute or otherwise
1.8       deraadt    28: #      use this file is hereby granted provided that
1.1       downsj     29: #      the above copyright notice and this notice are
1.8       deraadt    30: #      left intact.
1.1       downsj     31:
                     32: case "$-" in
                     33: *i*)   # we are interactive
                     34:        # we may have su'ed so reset these
1.25      rpe        35:        USER=$(id -un)
                     36:        UID=$(id -u)
1.1       downsj     37:        case $UID in
                     38:        0) PS1S='# ';;
                     39:        esac
1.12      david      40:        PS1S=${PS1S:-'$ '}
1.28      tb         41:        HOSTNAME=${HOSTNAME:-$(uname -n)}
1.1       downsj     42:        HOST=${HOSTNAME%%.*}
                     43:
                     44:        PROMPT="$USER:!$PS1S"
                     45:        #PROMPT="<$USER@$HOST:!>$PS1S"
                     46:        PPROMPT='$USER:$PWD:!'"$PS1S"
                     47:        #PPROMPT='<$USER@$HOST:$PWD:!>'"$PS1S"
                     48:        PS1=$PPROMPT
                     49:        # $TTY is the tty we logged in on,
                     50:        # $tty is that which we are in now (might by pty)
1.28      tb         51:        tty=$(tty)
                     52:        tty=${tty##*/}
1.12      david      53:        TTY=${TTY:-$tty}
1.21      rpe        54:        # $console is the system console device
1.26      rpe        55:        console=$(sysctl kern.consdev)
1.21      rpe        56:        console=${console#*=}
1.8       deraadt    57:
1.1       downsj     58:        set -o emacs
                     59:
1.32    ! mpf        60:        alias ls='ls -F'
1.1       downsj     61:        alias h='fc -l | more'
1.20      rpe        62:
1.1       downsj     63:        case "$TERM" in
1.3       marc       64:        sun*-s)
                     65:                # sun console with status line
1.22      rpe        66:                if [[ $tty != $console ]]; then
1.1       downsj     67:                        # ilabel
                     68:                        ILS='\033]L'; ILE='\033\\'
                     69:                        # window title bar
                     70:                        WLS='\033]l'; WLE='\033\\'
                     71:                fi
                     72:                ;;
                     73:        xterm*)
                     74:                ILS='\033]1;'; ILE='\007'
                     75:                WLS='\033]2;'; WLE='\007'
1.29      tb         76:                pgrep -qxs $PPID telnet && export TERM=xterms
1.1       downsj     77:                ;;
                     78:        *)      ;;
                     79:        esac
                     80:        # do we want window decorations?
1.22      rpe        81:        if [[ -n $ILS ]]; then
1.16      halex      82:                function ilabel { print -n "${ILS}$*${ILE}">/dev/tty; }
                     83:                function label { print -n "${WLS}$*${WLE}">/dev/tty; }
1.1       downsj     84:
                     85:                alias stripe='label "$USER@$HOST ($tty) - $PWD"'
                     86:                alias istripe='ilabel "$USER@$HOST ($tty)"'
                     87:
1.19      halex      88:                # Run stuff through this to preserve the exit code
                     89:                function _ignore { local rc=$?; "$@"; return $rc; }
                     90:
                     91:                function wftp { ilabel "ftp $*"; "ftp" "$@"; _ignore eval istripe; }
                     92:
                     93:                function wcd     { \cd "$@";     _ignore eval stripe; }
                     94:
                     95:                function wssh    { \ssh "$@";    _ignore eval 'istripe; stripe'; }
                     96:                function wtelnet { \telnet "$@"; _ignore eval 'istripe; stripe'; }
                     97:                function wsu     { \su "$@";     _ignore eval 'istripe; stripe'; }
                     98:
1.1       downsj     99:                alias su=wsu
                    100:                alias cd=wcd
                    101:                alias ftp=wftp
1.6       todd      102:                alias ssh=wssh
1.1       downsj    103:                alias telnet=wtelnet
1.18      halex     104:                eval stripe
                    105:                eval istripe
1.1       downsj    106:                PS1=$PROMPT
                    107:        fi
                    108:        alias quit=exit
                    109:        alias cls=clear
                    110:        alias logout=exit
                    111:        alias bye=exit
                    112:        alias p='ps -l'
                    113:        alias j=jobs
                    114:        alias o='fg %-'
1.20      rpe       115:        alias df='df -k'
                    116:        alias du='du -k'
1.28      tb        117:        alias rsize='eval $(resize)'
1.1       downsj    118: ;;
                    119: *)     # non-interactive
                    120: ;;
                    121: esac