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.

121 lines
2.8 KiB

  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. # RCSid:
  20. # $From: ksh.kshrc,v 1.4 1992/12/05 13:14:48 sjg Exp $
  21. #
  22. # @(#)Copyright (c) 1991 Simon J. Gerraty
  23. #
  24. # This file is provided in the hope that it will
  25. # be of use. There is absolutely NO WARRANTY.
  26. # Permission to copy, redistribute or otherwise
  27. # use this file is hereby granted provided that
  28. # the above copyright notice and this notice are
  29. # left intact.
  30. case "$-" in
  31. *i*) # we are interactive
  32. # we may have su'ed so reset these
  33. USER=$(id -un)
  34. UID=$(id -u)
  35. case $UID in
  36. 0) PS1S='# ';;
  37. esac
  38. PS1S=${PS1S:-'$ '}
  39. HOSTNAME=${HOSTNAME:-$(uname -n)}
  40. HOST=${HOSTNAME%%.*}
  41. PROMPT="$USER:!$PS1S"
  42. #PROMPT="<$USER@$HOST:!>$PS1S"
  43. PPROMPT='$USER:$PWD:!'"$PS1S"
  44. #PPROMPT='<$USER@$HOST:$PWD:!>'"$PS1S"
  45. PS1=$PPROMPT
  46. # $TTY is the tty we logged in on,
  47. # $tty is that which we are in now (might by pty)
  48. tty=$(tty)
  49. tty=${tty##*/}
  50. TTY=${TTY:-$tty}
  51. # $console is the system console device
  52. console=$(sysctl kern.consdev)
  53. console=${console#*=}
  54. set -o emacs
  55. alias ls='ls -F'
  56. alias h='fc -l | more'
  57. case "$TERM" in
  58. sun*-s)
  59. # sun console with status line
  60. if [[ $tty != $console ]]; then
  61. # ilabel
  62. ILS='\033]L'; ILE='\033\\'
  63. # window title bar
  64. WLS='\033]l'; WLE='\033\\'
  65. fi
  66. ;;
  67. xterm*)
  68. ILS='\033]1;'; ILE='\007'
  69. WLS='\033]2;'; WLE='\007'
  70. pgrep -qxs $PPID telnet && export TERM=xterms
  71. ;;
  72. *) ;;
  73. esac
  74. # do we want window decorations?
  75. if [[ -n $ILS ]]; then
  76. function ilabel { print -n "${ILS}$*${ILE}">/dev/tty; }
  77. function label { print -n "${WLS}$*${WLE}">/dev/tty; }
  78. alias stripe='label "$USER@$HOST ($tty) - $PWD"'
  79. alias istripe='ilabel "$USER@$HOST ($tty)"'
  80. # Run stuff through this to preserve the exit code
  81. function _ignore { local rc=$?; "$@"; return $rc; }
  82. function wftp { ilabel "ftp $*"; "ftp" "$@"; _ignore eval istripe; }
  83. function wcd { \cd "$@"; _ignore eval stripe; }
  84. function wssh { \ssh "$@"; _ignore eval 'istripe; stripe'; }
  85. function wtelnet { \telnet "$@"; _ignore eval 'istripe; stripe'; }
  86. function wsu { \su "$@"; _ignore eval 'istripe; stripe'; }
  87. alias su=wsu
  88. alias cd=wcd
  89. alias ftp=wftp
  90. alias ssh=wssh
  91. alias telnet=wtelnet
  92. eval stripe
  93. eval istripe
  94. PS1=$PROMPT
  95. fi
  96. alias quit=exit
  97. alias cls=clear
  98. alias logout=exit
  99. alias bye=exit
  100. alias p='ps -l'
  101. alias j=jobs
  102. alias o='fg %-'
  103. alias df='df -k'
  104. alias du='du -k'
  105. alias rsize='eval $(resize)'
  106. ;;
  107. *) # non-interactive
  108. ;;
  109. esac