bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell command history messing up when switching windows/slices in tm


From: Greg Wooledge
Subject: Re: Shell command history messing up when switching windows/slices in tmux
Date: Wed, 10 Apr 2019 08:50:26 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Apr 10, 2019 at 09:44:34AM +0200, Matej Vargovčík wrote:
> I had a problem losing bash history when switching between terminals in
> tmux. I reported the issue in tmux, but the developers have told me that
> it's a bash problem and I should report it here. Please see this thread for
> more details:
> https://github.com/tmux/tmux/issues/1671
> Thank you for looking into this matter

Each running instance of bash keeps its own copy of history in memory.
When you use the "history" command, or the up-arrow key, or any other
methods to review bash history, you get the list from that particular
instance of bash.

Bash loads history from the $HISTFILE on disk into memory at startup,
and writes history from memory into $HISTFILE on disk upon exit, unless
you use "history -a" or similar commands to modify the $HISTFILE while
bash is still running.

If you're looking for a real-time shared history among all concurrent
running instances of bash, there are ways to hack that into existence
with "history -a" and $PROMPT_COMMAND and so on.  But I'll warn you that
Korn shell does that real-time shared history thing, and I despise it.
I greatly prefer bash's isolated history, where each window can operate
independently without unrelated work flows bleeding into each other.
Or worse, if you're logging into a shared account (say, root), with ksh
you might accidentally get some other person's commands in your history.
With bash, at least you know you're always getting YOUR history.  No
surprise rm -rf * commands.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]