OIT Frequently Asked Questions


Problem: How do I change my prompt in ksh?
Entry: 0066

Solution:

Changing your prompt depends on what you want to do with it. The prompt is configured in your .profile. The variable is PS1. To set a prompt to reflect your hostname and current directory, you would have a line that looks like:
export PS1="{${HOSTNAME}:${PWD}:!} "
To have a prompt that reflects the current time, it would look like:
typeset -RZ2 _x1 _x2 _x3
let SECONDS=$(date '+3600*%H+60*%M+%S')
_s='(_x1=(SECONDS/3600)%24)==(_x2=(SECONDS/60)%60)==(_x3=SECONDS%60)'
TIME='"${_d[_s]}$_x1:$_x2:$_x3"'
export PS1=${TIME}
You can combine these two commands in this type of fashion:
export PS1="{${HOSTNAME}:${PWD}:${TIME}:!} "

Feel free to submit a request for help for any of the following reasons:

Main Menu