Using Escape Codes and Setting Window Title on PS1 for ksh (Korn Shell)

I set up the following in my ~/.profile for my ksh login:

export HOST=$(hostname)
 
export PS1=$(perl -e 'printf "33]0;${USER}@${HOST}:${PWD}07$"')

Unfortunately, ksh doesn't understand escape codes, so perl or awk is necessary to pull this off--or you can enter them literally via your editor. I like the perl route just for ease of maintenance.

This was inspired by: Setting window title via escape sequences. Of course, the bash version is *much* simpler:

export PS1="e]2;${USER}@${HOSTNAME}: ${PWD}a"

Other links of interest: