Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Another use for PRE_EXEC

May
12,957
172
I've been playing with PRE_EXEC lately. Two uses that have been discussed are placing a command timestamp on the command line and starting a command timer which could read (@TIMER) in POST_EXEC.

I have often wished I had a log of commands with timestamps. I don't like the command log because it records expanded commands and commands in batch files; the history log does neither of those. A pretty simple PRE_EXEC alias adds time/id stamps (like the command log) to the history log.

Code:
alias pre_exec `echos [%_date %_time] [%_pid]^^s >> %_hlogfile`

I get the likes of this.

Code:
v:\> echo This is a test.
This is a test.

v:\> tail /n 2 %_hlogfile
[2023-04-18 12:22:17] [3476] echo This is a test.
[2023-04-18 12:22:31] [3476] tail /n 2 %_hlogfile

That works well for me because I use global lists, guarded by SHRALIAS and populated at login from SHRALIAS's .SAV files. It would really screw things up if you read the the history log back into the history (say with HISTORY /R in TCStart).

Just a note: I'm surprised that so few users (apparently) use SHRALIAS.
 
Back
Top