[Ilugc] linux command history question?

  • From: knutties@xxxxxxxxx (Natarajan K)
  • Date: Thu Aug 18 23:14:20 2005

On 8/18/05, Natarajan K <knutties@xxxxxxxxx> wrote:

On 8/18/05, Sai Kiran <saikiranrgda@xxxxxxxxx> wrote:
You could use the history builtin command and the PROMPT_COMMAND
environment variable to achieve this purpose.

Setting you PROMPT_COMMAND to "history -w; history -r" will make sure
that you history is saved and restored after command is executed. You
should have been before every command is executed. PROMPT_COMMAND is
executed before every shell command is executed.

would also need to make sure you start off with an absolutely spotless
history :-) Otherwise you will history commands alternatively
overwriting your $HISTFILE.


Above solution won't work. That was too enthusiastic of me. Why it
won't work is the history write will spoil the synchronization. It
might write back stale history as one session's history does not get
updated automatically when another session executes a command. If we
had a counterpart to the PROMPT_COMMAND for executing certain commands
after every command then we would have had an easy solution.

I still feel we could play around with the PROMPT_COMMAND and the
history builtin to achieve history synchronization.

Natarajan
-- 
http://puggy.symonds.net/~natarajan

Other related posts: