Date stamping commands in the history file in ksh

Date stamping commands in the history file in ksh

Post by Expr » Sat, 22 Nov 1997 04:00:00



Hi All,

I need to date stamp commands in the history file as the subject says.

I am using the Korn shell with the default history file (.sh_history and
size of 128 running on under MAX/OS by Concurrent.

I have tried things like PS1='$(date>>$HOME/.sh_history)\$' in the
profile.? This works when you log in but doesn't work after that.

How can I get it to work every time the prompt is displayed??

I presume that I'm on the right track trying to modify the primary prompt (PS1).
I know that I could do an alias for each command and script for the 30 - 40
that we commonly use but that wouldn't cover all commands.

Any help is much appreciated.

TIA
Craig


 
 
 

Date stamping commands in the history file in ksh

Post by Fred Su » Mon, 24 Nov 1997 04:00:00



Quote:> I need to date stamp commands in the history file as the subject says.
> I am using the Korn shell with the default history file (.sh_history and
> size of 128 running on under MAX/OS by Concurrent.
> I have tried things like PS1='$(date>>$HOME/.sh_history)\$' in the
> profile.? This works when you log in but doesn't work after that.

To the best of my knowledge, you can't execute commands from within Korn
shell prompts.  You can, however, append strings to the history file
whenever you want using the 'print -s ...' command -- have a look at the
ksh man page.  Maybe you can integrate this with what you want, somehow ...

If it's of any help, you _can_ do this using Bash.

Fred Surr
Melbourne

 
 
 

Date stamping commands in the history file in ksh

Post by James R. Mart » Thu, 27 Nov 1997 04:00:00



: I need to date stamp commands in the history file as the subject says.
: I am using the Korn shell with the default history file (.sh_history and
: size of 128 running on under MAX/OS by Concurrent.
: I have tried things like PS1='$(date>>$HOME/.sh_history)\$' in the
: profile.? This works when you log in but doesn't work after that.

trap "PS1='\$(date)>>~/.sh_history)\\$ '" DEBUG

P.S. Don't you want something in your interactive prompt?

trap "PS1='\$(date | tee -ai ~/.sh_history)\\$ '" DEBUG

BTW, ksh93 _does_ evaluate variable _and_ command substitution in PS1,
as well as having "tee" (and "date"?) as builtin commands.

--
james martin

 
 
 

1. Date stamping commands in the shell command history file

Hi All,

I need to date stamp commands in the history file as the subject says.

I am using the Korn shell with the default history file (.sh_history and
size of 128.

I have tried things like PS1='$(date>>$HOME/.sh_history)\$' in the
profile.  This works when you log in but doesn't work after that.

How can I get it to work every time the prompt is displayed??

I presume that I'm on the right track trying to modify the primary prompt.
I know that I could do an alias for each command and script for the 30 - 40
that we commonly use but that wouldn't cover all commands.

Any help is much appreciated.

TIA
Craig

2. * Diamond Stealth 64 Video VRAM works in X ... sorta *

3. Compare file modification date using tcsh built-ins

4. Redirects on Apacje 1.2b8 1.2b10

5. What's 'side effects' of Ksh built-ins?

6. Linux Frequently Asked Questions with Answers (Part 4 of 6)

7. Netscape plug-ins, helper files, Acrobat etc.

8. Filemgr

9. ksh: 2 Q's, command completion & command history?

10. KSH - Convert date to unix time stamp

11. Does DIFF command check date/time stamp ?

12. Date or Time Stamp Command Help

13. ksh hangs attempting to lock history file on NFS mounted file system