Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
3.9 KiB

22 years ago
  1. :
  2. # $OpenBSD: ksh.kshrc,v 1.11 2002/12/08 22:40:45 marc Exp $
  3. #
  4. # NAME:
  5. # ksh.kshrc - global initialization for ksh
  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. # 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. case "$-" in
  32. *i*) # we are interactive
  33. # we may have su'ed so reset these
  34. # NOTE: SCO-UNIX doesn't have whoami,
  35. # install whoami.sh
  36. USER=`whoami 2>/dev/null`
  37. USER=${USER:-`id | sed 's/^[^(]*(\([^)]*\)).*/\1/'`}
  38. UID=`id -u`
  39. case $UID in
  40. 0) PS1S='# ';;
  41. esac
  42. PS1S=${PS1S:-'$ '}
  43. HOSTNAME=${HOSTNAME:-`uname -n`}
  44. HOST=${HOSTNAME%%.*}
  45. PROMPT="$USER:!$PS1S"
  46. #PROMPT="<$USER@$HOST:!>$PS1S"
  47. PPROMPT='$USER:$PWD:!'"$PS1S"
  48. #PPROMPT='<$USER@$HOST:$PWD:!>'"$PS1S"
  49. PS1=$PPROMPT
  50. # $TTY is the tty we logged in on,
  51. # $tty is that which we are in now (might by pty)
  52. tty=`tty`
  53. tty=`basename $tty`
  54. TTY=${TTY:-$tty}
  55. set -o emacs
  56. alias ls='ls -CF'
  57. alias h='fc -l | more'
  58. # the PD ksh is not 100% compatible
  59. case "$KSH_VERSION" in
  60. *PD*) # PD ksh
  61. ;;
  62. *) # real ksh ?
  63. [ -r $HOME/.functions ] && . $HOME/.functions
  64. set -o trackall
  65. ;;
  66. esac
  67. case "$TERM" in
  68. sun*-s)
  69. # sun console with status line
  70. if [ "$tty" != "$console" ]; then
  71. # ilabel
  72. ILS='\033]L'; ILE='\033\\'
  73. # window title bar
  74. WLS='\033]l'; WLE='\033\\'
  75. fi
  76. ;;
  77. xterm*)
  78. ILS='\033]1;'; ILE='\007'
  79. WLS='\033]2;'; WLE='\007'
  80. parent="`ps -ax 2>/dev/null | grep $PPID | grep -v grep`"
  81. case "$parent" in
  82. *telnet*)
  83. export TERM=xterms;;
  84. esac
  85. ;;
  86. *) ;;
  87. esac
  88. # do we want window decorations?
  89. if [ "$ILS" ]; then
  90. ilabel () { print -n "${ILS}$*${ILE}">/dev/tty; }
  91. label () { print -n "${WLS}$*${WLE}">/dev/tty; }
  92. alias stripe='label "$USER@$HOST ($tty) - $PWD"'
  93. alias istripe='ilabel "$USER@$HOST ($tty)"'
  94. wftp () { ilabel "ftp $*"; "ftp" $*; eval istripe; }
  95. wcd () { \cd "$@" && eval stripe; }
  96. wssh ()
  97. {
  98. "ssh" "$@"
  99. eval istripe
  100. eval stripe
  101. }
  102. wtelnet ()
  103. {
  104. "telnet" "$@"
  105. eval istripe
  106. eval stripe
  107. }
  108. wrlogin ()
  109. {
  110. "rlogin" "$@"
  111. eval istripe
  112. eval stripe
  113. }
  114. wsu ()
  115. {
  116. "su" "$@"
  117. eval istripe
  118. eval stripe
  119. }
  120. alias su=wsu
  121. alias cd=wcd
  122. alias ftp=wftp
  123. alias ssh=wssh
  124. alias telnet=wtelnet
  125. alias rlogin=wrlogin
  126. eval stripe
  127. eval istripe
  128. PS1=$PROMPT
  129. fi
  130. alias quit=exit
  131. alias cls=clear
  132. alias logout=exit
  133. alias bye=exit
  134. alias p='ps -l'
  135. alias j=jobs
  136. alias o='fg %-'
  137. alias ls='ls -gCF'
  138. # add your favourite aliases here
  139. OS=${OS:-`uname -s`}
  140. case $OS in
  141. HP-UX)
  142. alias ls='ls -CF'
  143. ;;
  144. *BSD)
  145. alias df='df -k'
  146. alias du='du -k'
  147. ;;
  148. esac
  149. alias rsize='eval `resize`'
  150. ;;
  151. *) # non-interactive
  152. ;;
  153. esac
  154. # commands for both interactive and non-interactive shells
  155. # is $1 missing from $2 (or PATH) ?
  156. no_path () {
  157. eval _v="\$${2:-PATH}"
  158. case :$_v: in
  159. *:$1:*) return 1;; # no we have it
  160. esac
  161. return 0
  162. }
  163. # if $1 exists and is not in path, append it
  164. add_path () {
  165. [ -d ${1:-.} ] && no_path $* && eval ${2:-PATH}="\$${2:-PATH}:$1"
  166. }
  167. # if $1 exists and is not in path, prepend it
  168. pre_path () {
  169. [ -d ${1:-.} ] && no_path $* && eval ${2:-PATH}="$1:\$${2:-PATH}"
  170. }
  171. # if $1 is in path, remove it
  172. del_path () {
  173. no_path $* || eval ${2:-PATH}=`eval echo :'$'${2:-PATH}: |
  174. sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;"`
  175. }