1# $OpenBSD: ksh.kshrc,v 1.32 2018/05/16 14:01:41 mpf Exp $ 2# 3# NAME: 4# ksh.kshrc - global initialization for ksh 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 28# use this file is hereby granted provided that 29# the above copyright notice and this notice are 30# left intact. 31 32case "$-" in 33*i*) # we are interactive 34 # we may have su'ed so reset these 35 USER=$(id -un) 36 UID=$(id -u) 37 case $UID in 38 0) PS1S='# ';; 39 esac 40 PS1S=${PS1S:-'$ '} 41 HOSTNAME=${HOSTNAME:-$(uname -n)} 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) 51 tty=$(tty) 52 tty=${tty##*/} 53 TTY=${TTY:-$tty} 54 # $console is the system console device 55 console=$(sysctl kern.consdev) 56 console=${console#*=} 57 58 set -o emacs 59 60 alias ls='ls -F' 61 alias h='fc -l | more' 62 63 case "$TERM" in 64 sun*-s) 65 # sun console with status line 66 if [[ $tty != $console ]]; then 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' 76 pgrep -qxs $PPID telnet && export TERM=xterms 77 ;; 78 *) ;; 79 esac 80 # do we want window decorations? 81 if [[ -n $ILS ]]; then 82 function ilabel { print -n "${ILS}$*${ILE}">/dev/tty; } 83 function label { print -n "${WLS}$*${WLE}">/dev/tty; } 84 85 alias stripe='label "$USER@$HOST ($tty) - $PWD"' 86 alias istripe='ilabel "$USER@$HOST ($tty)"' 87 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 99 alias su=wsu 100 alias cd=wcd 101 alias ftp=wftp 102 alias ssh=wssh 103 alias telnet=wtelnet 104 eval stripe 105 eval istripe 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 %-' 115 alias df='df -k' 116 alias du='du -k' 117 alias rsize='eval $(resize)' 118;; 119*) # non-interactive 120;; 121esac 122