830N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
830N/A# Use is subject to license terms.
830N/A# This file is sourced by interactive ksh93 shells before ${HOME}/.kshrc
830N/A# Enable "gmacs"+"multiline" editor mode if the user did not set an
830N/A# input mode yet (for example via ${EDITOR}, ${VISUAL} or any
830N/Aif [[ "$(set +o)" != ~(Er)--(gmacs|emacs|vi)( .*|) ]] ; then
830N/A # enable multiline input mode
830N/A # enable globstar mode (match subdirs with **/)
830N/A# Set a default prompt (<username>@<hostname>:<path><"($|#) ">) if
830N/A# then variable does not exist in the environment.
830N/A# 1. Define "ellipsis", either Unicode #2026 for unicode locales
830N/A# ([[ "${LC_ALL}/${LANG}" = ~(Elr)(.*UTF-8/.*|/.*UTF-8) ]]
830N/A# ensures that the pattern matches the leftmost sequence
830N/A# containing *.UTF-8, allowing to match either LC_ALL or
830N/A# LANG when LC_ALL is not set)
830N/A# 2. If PWD is within HOME replace value of HOME with '~'
830N/A# If the PWD is longer than 30 charatcers shorten it to 30 chars
830N/A# print '#' for user "root" and '$' for normal users
830N/A# - printf "%*s\r%s" COLUMNS "") # is used at the beginning to
830N/A# work around a bug in the "multiline" handling code which
830N/A# causes the shell to override its own prompt when the edit
830N/A# line overflows (this happens if the terminal cursor
830N/A# position is not 0 when PS1 is printed).
830N/A# - PS1 will initially be empty until either...
830N/A# a) ... someone sets the variable
830N/A# b) ... the prompt is displayed for the first time (default is
830N/A# '$ ' for normal users and '# ' for user "root")
830N/A# unless PS1 gets "unset" first.
830N/Aif [[ "$(set)" != ~(E)PS1= && "${PS1}" == '' ]] ; then
830N/A PS1='$(set +o xtrace +o errexit
830N/A printf "%*s\r%s" COLUMNS ""
830N/A [[ "${LC_ALL}/${LANG}" == ~(Elr)(.*UTF-8/.*|/.*UTF-8) ]] &&
830N/A printf "\u[2026]\n" || print "..." ; }"
830N/A p="${PWD/~(El)${HOME}/\~}"
830N/A print -r -n -- "${ellip}${p:${#p}-30:30}" ||
830N/A [[ "${LOGNAME}" == "root" ]] && print -n "# " || print -n "\$ "