Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 21 |
Nodes: | 6 (0 / 6) |
Uptime: | 28:56:14 |
Calls: | 139 |
Files: | 91 |
Messages: | 42,690 |
In debian bookworm, xfce desktop, different virtual terminals have a different history if same user presses "up key" in different virtual terminals ?
Is this something that can be changed so history is shared between virtual terminals?
Is this something that can be changed so history is shared between virtual terminals?
On 2024-07-27 23:08, Greg Wooledge wrote:
On Sat, Jul 27, 2024 at 22:50:17 +0100, mick.crane wrote:
In debian bookworm, xfce desktop, different virtual terminals have a different history if same user presses "up key" in different virtual terminals ?
As your subject says, this is "bash history". And yes, each instance of bash has its own separate history. It has nothing to do with yourWhere is it if not in ~/.bash_history?
terminal emulator or your desktop environment.
Bash reads its history from a file (~/.bash_history by default) at
startup time, manages it in memory while running, and writes it back
out to the history file upon exiting.
Does this separate history get written to ~/.bash_history when terminal emulation thing is closed?
On 2024-07-27 23:08, Greg Wooledge wrote:
On Sat, Jul 27, 2024 at 22:50:17 +0100, mick.crane wrote:
In debian bookworm, xfce desktop, different virtual terminals
have a different history if same user presses "up key" in
different virtual terminals ?
As your subject says, this is "bash history". And yes, each
instance of bash has its own separate history. It has nothing to
do with your terminal emulator or your desktop environment.
Where is it if not in ~/.bash_history?
Bash reads its history from a file (~/.bash_history by default) at
startup time, manages it in memory while running, and writes it
back out to the history file upon exiting.
Does this separate history get written to ~/.bash_history when
terminal emulation thing is closed?
In debian bookworm, xfce desktop, different virtual terminals have a different history if same user presses "up key" in different virtual terminals ?
Is this something that can be changed so history is shared between virtual terminals?
On 2024-07-27 23:58, Greg Wooledge wrote:
You need to specify *exactly* what you're doing.
Sometimes I forget where I was after closing a virtual terminal and it
would be handy to see the history
in a new terminal, where I "cd'd" to for example.
stuff like that.
On Sat, Jul 27, 2024 at 2:50 PM mick.crane <mick.crane@gmail.com> wrote:
Is this something that can be changed so history is shared between
virtual terminals?
Yes.
[...]
From my .bashrc file, I have the following history related settings:
# No limit on running shell history size
HISTSIZE=-1
# No limit on lines saved in history file
HISTFILESIZE=-1
# Enable timestamps in bash_history
HISTTIMEFORMAT="[%F %T %z] "
# Stop history being clobbered if there are multiple shells open
shopt -s histappend
# Immediately append history
PROMPT_COMMAND='history -a'
If you really want to try sharing history immediately between shells, use this:
PROMPT_COMMAND='history -a; history -n'
Note that PROMPT_COMMAND executes before printing a prompt, which
means after executing a command. So, if using "history -n", then
other shells will not load the shared history until a new prompt is
printed (e.g., hitting the ENTER key to display a new prompt).
For the record, I deal with the expected conflicts when merging
history files across machines by using a simple python program that
parses the history file (that includes the timestamps), discards the
conflict markers, orders by timestamps, and writes it back out. It is
by no means perfect, but "good enough for me".
For those worried about the unbounded history, I started doing that
about ten years ago and my work history is currently just shy of
180,000 commands. It would likely be less if I turned on the
"erasedups" feature, but I like to keep the context. And I've seen
comments about folks who have multiple decades of shell history. On
modern machines, it simply isn't an issue.
mrc
In debian bookworm, xfce desktop, different virtual terminals have a different history if same user presses "up key" in different virtual terminals ?
Is this something that can be changed so history is shared between
virtual terminals?
mick
[...]
to keep my own setup consistent and to not keep certain
things in history i actually do the opposite of what you
want because i want certain commands already preloaded in
my history for all windows when i start up and then i adjust
my environment based upon which pty or directory i'm in.
Le 7/28/24 à 12:19, songbird a écrit :
to keep my own setup consistent and to not keep certain things in
history i actually do the opposite of what you want because i want
certain commands already preloaded in my history for all windows
when i start up and then i adjust my environment based upon which
pty or directory i'm in.
I'm scratching my head here.
Can anyone provide a solid example or reason why preloading commands
in history is necessary?