Ottavio Caruso wrote in <CAEJNuHymoGWLryUFeLYF_AH-qfed1ymvayhByFsbV+-9WX\ oP=q...@mail.gmail.com>: |Hi, | |[hoping my post doesn't arrive duplicated or triplicated] | |How do you set the prompt in ksh? The man page doesn't seem to help. |OpenBSD ksh has a different manpage. Compare: |https://man.openbsd.org/ksh.1#PS1 |and |https://netbsd.gw.com/cgi-bin/man-cgi?ksh | |For example: |PS1="\u@\h:\w\$ " | |is not expanded.
These things are totally non-portable. I setup a shell environment with some basics via ~/.profile (that is made to be found by all shells), and then interactive ~/.shrc (symlinked so to be found the way the shell(s) want it). And that uses the basic environment, for example $OSTYPE, $HOSTNAME etc., to create a shell prompt via variables. Somewhat heavily stripped (and embedded in a .profile environment) eval "___isinc=\$___SHRC$$" [ -z "${___isinc}" ] && { eval "___SHRC${$}=YES" export ___SHRC${$} case ${-} in *i*|*m*) ... # Determine shell type; aux while there ps1s= ps1S= ps1e= ps1W= case "${0}" in *ksh*) unset BASH_VERSION ___MKSH ___SHTYPE=ksh if [ "${KSH_VERSION}" != "${KSH_VERSION%%MIRBSD*}" ]; then export ___MKSH=YES eval "ps1s=\$'\e[31m' ps1S=\$'\e[38;5;203m' ps1e=\$'\e[0m'" # There were some problems in between.. if [ "${KSH_VERSION}" != "${KSH_VERSION%%R4[0-6]*}" ]; then trap 'echo; echo INTERRUPT' INT ___do_exit() { trap ___on_exit EXIT unalias exit exit } trap -- EXIT set -o ignoreeof alias exit=___do_exit fi bind ^O=delete-word-forward else ps1s="" ps1S="" ps1e="" # XXX \e <> OpenBSD? I think newer OpenBSD has support for \[..\], but i may be mistaken. This code is very (, very) old. fi ;; *bash*) unset KSH_VERSION ___MKSH ___SHTYPE=bash ps1s="\[\e[31m\]" ps1S="\[\e[38;5;203m\]" ps1e="\[\e[0m\]" shopt login_shell >/dev/null 2>&1 && trap -- EXIT ;; *yash*) unset BASH_VERSION KSH_VERSION ___MKSH ___SHTYPE=yash ps1s="\[\e[31m\]" ps1S="\[\e[38;5;203m\]" ps1e="\[\e[0m\]" set -o emacs ;; *) unset KSH_VERSION ___MKSH BASH_VERSION ___SHTYPE= # /bin/sh may be some BSD ash(1) if [ "${OSTYPE}" = freebsd ] || [ "${OSTYPE}" = dragonfly ]; then ps1W='\W' fi ;; esac export ___SHTYPE ... # Prompts are very complicated to get case "${TERM}" in *dumb*) ps1s= ps1S= ps1e=;; *256color*) ps1s=$ps1S;; *) if command -v tput >/dev/null 2>&1 && ( [ "`tput colors`" -ge 256 ] ); then ps1s=$ps1S fi ;; esac [ "${UID}" -eq 0 ] && PS1='#' || PS1='$' if ( [ "${HISTSIZE##84}" = 42 ] ) > /dev/null 2>&1 ; then # bash(1)/*ksh(1)? if [ -n "${___SHTYPE}" ]; then PS1="${ps1s}#?\$?|${HOSTNAME%%.*}:\${PWD##*/}${PS1}${ps1e} " else PS1="${ps1s}#${HOSTNAME%%.*}:${ps1W}${PS1}${ps1e} " fi else PS1="${ps1s}#${HOSTNAME}${PS1}${ps1e} " fi PS2='> ' export PS1 PS2 ... |Thanks What a mess. |-- |Ottavio Caruso --End of <CAEJNuHymoGWLryUFeLYF_AH-qfed1ymvayhByFsbV+-9WXoP=Q@mail.gmail\ .com> --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)