Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding "date" to command prompt and HISTFILE

Status
Not open for further replies.

jxfish2

Technical User
Jan 24, 2002
183
US
Can anyone tell me how to add a date / time stamp to the HISTFILE under Korn Shell?

Can anyone tell me how to add a date / time stamp to the command prompt under Korn Shell?

My current command prompt looks like this:

<User_ID> @ <Hostname> | <Current_Directory>
-->

I want to add the date to the first line, like this:

<User_ID> @ <Hostname> | <Curr_Dir> (<date>)
-->

Example:

root @ anysys | /etc (May 6, 12:42:16)

"pwd" is a system call, and updates dynamically, but "date" doesn't seem to want to update automatically.

I'm checking the ksh man pages, and the Korn Shell book, but haven't had any luck yet...

Any help would be greatly appreciated...

TIA

Joe F...
HP-UX SysAdm
 
Hi, What I've done in the past is set PS1 in the .profile and had it work. For instance:

"
# Set the prompt characters

PS1='${OTHER}'`hostname`'${GREEN}${PWD}/
${WHITE}'`whoami`'${CYAN}'`date`' > '

export PS1

We kinda have a desire here to add color, that's why the colors are there. This does seem to work, use as an example and take it where you want to. Good luck...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top