Matus UHLAR - fantomas wrote:
you could try to insert the current date into your prompt (PS1) string, if you want it this way. also, looking at 'man bash', there's special variable: PROMPT_COMMAND If set, the value is executed as a command prior to issuing each primary prompt.If I can print the date just before each command is executed, I can always be able to get a sense of how long each command has taken.if not each command, using 'time command' rells you much more and also tells you exactly how much did command take to complete, while seeing two times you have to substract it (not so easy sometimes, 10:23 vs 09:47), if you haven't lost it from your screen already...
Good point.For subtracting times I use 'echo $((`date --date=<T2> +%s` - `date --date=<T1> +%s`)). This gives me the difference in seconds. I can then divide by 60 for minutes, etc. I know is not precise (to milliseconds for example), but it suffices for my purpose.
However, I do admit that using time for commands is probably a lot better. Besides, I can never get a "precise" time with just inserting the date in the prompt because if the terminal sits idle for some time, the time in which a command starts executing can not be correctly determined this way because you never really know how much time went by (by just looking at the prompt) before the command started execution.
Wouldn't it be nice if bash would allow a "secondary" definable "prompt" that would be issued just *before* command execution? Then stuff like printing date before commands could be done. Just a wish. :-) But thanks for input.
-- Sincerely Jose Alburquerque