Tuesday, September 15, 2020

How do you get different $PS1 for /bin/sh and /bin/ksh?

Hi,

I have this in ~/.kshrc :

PS1="\u@\h:\w\$ "

which works fine in ksh:

oc@OpenBSD:~$

However, if I open a sh subshell, I get:

\u@OpenBSD:\w$

which is not very nice. The only hack I've found is to append this to
~/.profile:


if [ -n "$KSH_VERSION" ]; then
if [ -f "$HOME/.kshrc" ]; then
. "$HOME/.kshrc"
fi
fi

I wonder if there is a more elegant solution.


--
Ottavio Caruso

No comments:

Post a Comment