I'm very new to AIX as well as ksh, but I currently have some downtime at work and am trying to configure my prompt to be both colored and show my current location.

At the moment, I get the correct path only once on login, afterwards it continues to show my user directory. Colors work fine. logname and hostname are correct.

PS1="$(echo "\033[35m`logname`\033[34m@\033[35m`hostname` \033[36m`pwd`\033[1;35m\n\>\033[0m") "

Can't show a screenshot, but sample output would look like this in any directory:

userid@hostname /home/look/a/subfolder

I tried a bunch of different versions but I either couldn't get it to show anything or all special characters appeared as written in .profile.

Any ideas what I'm doing wrong?

Edit: Thanks to Stéphane, ESC+CTRL+V works, it's ksh88. AIX 7.1

  • The substitutions, e.g. `pwd` are executed when you set the variable PS1, not when the shell displays the prompt.
    – Bodo
    Jan 19, 2022 at 13:11
  • Pressing Esc, followed by Ctrl+V may tell you the version. It's likely some versions of ksh88 since ${.sh.version} is not supported. Jan 19, 2022 at 13:28
  • There should be a letter after ksh88 (likely i) which gives the version. Jan 19, 2022 at 13:47

2 Answers 2



eval "$(print "
  fg_magenta='\033[35m' fg_blue='\033[34m' fg_cyan='\033[36m' 
  nl='\n' bold='\033[1m' sgr0='\033[m'")"

PS1="$fg_magenta$LOGNAME$fg_blue@$fg_magenta$(uname -n) $fg_cyan\$PWD$bold$fg_magenta$nl>$sgr0 "

That is, the things that don't change during a shell session, expand them upon assignment (unless they may contain $, `, \, ! characters, but for $PWD which changes any time you wan to store a literal $PWD into $PS1 for that $PWD to be expanded upon prompt expansion¹

¹ Beware that if those expansions contain ! characters, they will be expanded to the current history number, so strictly speaking that should be ${PWD//!/!!} (${param//pattern/replacement} is a ksh93 operator though)

  • Yep, perfect colored prompt. Thank you as well! :) Jan 19, 2022 at 14:03

I've always used

$ '
  • Perfect. Works fine. Thank you! Jan 19, 2022 at 13:36
  • Zum Wohl und Vergnügen. Jan 19, 2022 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .