Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I *____knew* I had some reason for not logging you off... If I could just remember what it was.


devel / comp.unix.shell / Re: capture the maximum amount of cmd history in bash

SubjectAuthor
* capture the maximum amount of cmd history in bashhput
+* Re: capture the maximum amount of cmd history in bashJanis Papanagnou
|+* Re: capture the maximum amount of cmd history in bashEli the Bearded
||`* Re: capture the maximum amount of cmd history in bashJanis Papanagnou
|| `- Re: capture the maximum amount of cmd history in bashEli the Bearded
|+- Re: capture the maximum amount of cmd history in bashJohn-Paul Stewart
|`* Re: capture the maximum amount of cmd history in bashhput
| +* Re: capture the maximum amount of cmd history in bashEli the Bearded
| |`* I'm curious; how do you do it? (Was: capture the maximum amount of cmd history iKenny McCormack
| | `* Re: I'm curious; how do you do it? (Was: capture the maximum amount of cmd histoEli the Bearded
| |  `- Re: I'm curious; how do you do it? (Was: capture the maximum amountDavid W. Hodgins
| `- Re: capture the maximum amount of cmd history in bashJavier
`- Re: capture the maximum amount of cmd history in bashGrant Taylor

1
capture the maximum amount of cmd history in bash

<87czie6mbm.fsf@local.lan>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5152&group=comp.unix.shell#5152

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
From: hpu...@zohomail.com (hput)
Newsgroups: comp.unix.shell
Subject: capture the maximum amount of cmd history in bash
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Message-ID: <87czie6mbm.fsf@local.lan>
Cancel-Lock: sha1:U29X/cJG8yTfcWP3KkppCDjIZeU=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 4
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Tue, 22 Mar 2022 11:25:49 -0400
X-Received-Bytes: 926
 by: hput - Tue, 22 Mar 2022 15:25 UTC

Can anyone post some examples of how to setup bash configuration
files to capture the maximum amount of command history. When, even
though it is a single user host, often, multiple shells come into
play.

Re: capture the maximum amount of cmd history in bash

<t1cts6$p7d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5153&group=comp.unix.shell#5153

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Tue, 22 Mar 2022 17:35:18 +0100
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <t1cts6$p7d$1@dont-email.me>
References: <87czie6mbm.fsf@local.lan>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Mar 2022 16:35:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a44e464f443ec47a0bb95e6dff82c680";
logging-data="25837"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19k0eetPGg2X07TajlqIldr"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:6s/CZP66Ly78VaOldrMqdDk9OkM=
In-Reply-To: <87czie6mbm.fsf@local.lan>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 22 Mar 2022 16:35 UTC

On 22.03.2022 16:25, hput wrote:
> Can anyone post some examples of how to setup bash configuration
> files to capture the maximum amount of command history.

What do you mean by that?

Capture the actual contents? Then use: fc -l 1

Or make history memory for shell windows as large as possible?

You can define any size by setting the HISTSIZE variable, as in

HISTSIZE=1000000

Since the history will be stored in a file (or maybe temporarily in
memory depending on shell), the limit is basically a runtime limit,
depending on your (available and used) system resources.

> When, even
> though it is a single user host, often, multiple shells come into
> play.

It may make sense to increase the default value for HISTSIZE (which
is typically around 500 lines), but often other additional approaches
might also serve one's needs. For example I defined a separate HISTFILE
for every shell instance; for me that makes sense because I usually
have a few windows for compiling stuff, some for testing, some for
playing, some for specific projects, one for managing web content and
servers, etc. So each history file needs not to store that many lines
because if I stay in the domain the commands re-appear frequently and
don't get pushed off the far end of the history queue by commands from
another domain. So I have in a shell resource file that is called from
my $HOME/.profile these lines defined

TTY=$( tty )
TTY=${TTY#/dev/}
TTY=${TTY//\//_}
export HISTFILE=${HOME}/.sh_history_${TTY}
export HISTSIZE=1000

to create history files named individually for each shell window.

Janis

Re: capture the maximum amount of cmd history in bash

<eli$2203221321@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5156&group=comp.unix.shell#5156

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Tue, 22 Mar 2022 17:39:44 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2203221321@qaz.wtf>
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me>
Injection-Date: Tue, 22 Mar 2022 17:39:44 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="5461"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Tue, 22 Mar 2022 17:39 UTC

In comp.unix.shell, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> On 22.03.2022 16:25, hput wrote:
>> Can anyone post some examples of how to setup bash configuration
>> files to capture the maximum amount of command history.

In bash I've seen this trick:

PROMPT_COMMAND='history -a >(logger -t "user $(id -u); at $(date +%s); in ${PWD}"'

Then ensure logs are sent off-system.

> Since the history will be stored in a file (or maybe temporarily in
> memory depending on shell), the limit is basically a runtime limit,
> depending on your (available and used) system resources.

That's why you write to system logs an use network logging.

>> When, even though it is a single user host, often,
multiple shells come into
>> play.
/bin/sh or `busybox sh` will frustrate your attempts to keep history.

> For example I defined a separate
> HISTFILE for every shell instance; for me that makes sense because I
> usually have a few windows for compiling stuff, some for testing, some
> for playing, some for specific projects, one for managing web content
> and servers, etc.

For myself, I do something quite similar with tty named history files.

Elijah
------
not a history maximalist

Re: capture the maximum amount of cmd history in bash

<j9uljiF544dU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5158&group=comp.unix.shell#5158

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: jpstew...@personalprojects.net (John-Paul Stewart)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Tue, 22 Mar 2022 15:16:01 -0400
Lines: 28
Message-ID: <j9uljiF544dU1@mid.individual.net>
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Trace: individual.net zomk5naojdyh+pV0v8G++wp5lvhEo3m2GxZZucEDsrMZ9NdZgr
Cancel-Lock: sha1:NFiAe6FystyIec6eUXJu1Y+P1Vg=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Content-Language: en-CA
In-Reply-To: <t1cts6$p7d$1@dont-email.me>
 by: John-Paul Stewart - Tue, 22 Mar 2022 19:16 UTC

On 2022-03-22 12:35, Janis Papanagnou wrote:
>
> It may make sense to increase the default value for HISTSIZE (which
> is typically around 500 lines), but often other additional approaches
> might also serve one's needs. For example I defined a separate HISTFILE
> for every shell instance; for me that makes sense because I usually
> have a few windows for compiling stuff, some for testing, some for
> playing, some for specific projects, one for managing web content and
> servers, etc.

I've taken the opposite approach with HISTFILE: I want all shell
windows to share a common (and up-to-date) history by setting:

PROMPT_COMMAND='history -a; history -r'

That ensures that each time a new shell prompt is displayed, the history
(i.e., the last command run) gets appended to HISTFILE, which then gets
re-read. That re-reading means that the last command typed in one shell
instance (xterm, in my case) is picked up by other shell sessions the
next time I do something in each.

Appending to the history file in PROMPT_COMMAND also has the side effect
of minimizing history loss in the event of an unclean shutdown. Only
the last command is lost from the history instead of the entire shell
session.

So that's another approach for the OP to consider, depending on what was
meant by "capture the maximum amount of command history".

Re: capture the maximum amount of cmd history in bash

<t1de7c$fjf$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5160&group=comp.unix.shell#5160

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Tue, 22 Mar 2022 15:14:47 -0600
Organization: TNet Consulting
Message-ID: <t1de7c$fjf$1@tncsrv09.home.tnetconsulting.net>
References: <87czie6mbm.fsf@local.lan>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 22 Mar 2022 21:14:20 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="15983"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <87czie6mbm.fsf@local.lan>
Content-Language: en-US
 by: Grant Taylor - Tue, 22 Mar 2022 21:14 UTC

On 3/22/22 9:25 AM, hput wrote:
> Can anyone post some examples of how to setup bash configuration files
> to capture the maximum amount of command history. When, even though
> it is a single user host, often, multiple shells come into play.

It's not an answer to your question. But I would feel remiss if I
didn't point out that:

Shell history files are inherently owned by the user running the shell.
As such, said user will almost invariable have full access to modify the
file(s) to their heart's content.

I strongly suggest that you step back and clearly think about and define
/ state what your goal is in messing with shell history files.

I've worked many places that tried to use shell history as a secondary
means of auditing. It always and invariable failed in one or more ways.
Not the least of which is `kill -9 $$` to avoid most if not all
history logging at time of shell exit.

--
Grant. . . .
unix || die

Re: capture the maximum amount of cmd history in bash

<t1fkji$vnf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5178&group=comp.unix.shell#5178

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Wed, 23 Mar 2022 18:15:30 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <t1fkji$vnf$1@dont-email.me>
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me>
<eli$2203221321@qaz.wtf>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 23 Mar 2022 17:15:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="08198feb9e6c50a0a9f7bba497bf4b5c";
logging-data="32495"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+e3JTfFa+Z9eJgdf7lqaiB"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:9S/gwJYNGugG1+R6dgnacXNcH6Q=
In-Reply-To: <eli$2203221321@qaz.wtf>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Wed, 23 Mar 2022 17:15 UTC

On 22.03.2022 18:39, Eli the Bearded wrote:
> In comp.unix.shell, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
>>
> In bash I've seen this trick:
>
> PROMPT_COMMAND='history -a >(logger -t "user $(id -u); at $(date +%s); in ${PWD}"'
>
> Then ensure logs are sent off-system.
>
>> Since the history will be stored in a file (or maybe temporarily in
>> memory depending on shell), the limit is basically a runtime limit,
>> depending on your (available and used) system resources.
>
> That's why you write to system logs an use network logging.

I'm not sure whether that's a solution for the history, typed commands
to be easily retrieved for re-running them or re-running them edited.
A logger's purpose is different to a shell history's purpose, isn't it?

I seem to recall that there's an additional issue with bash's history,
where someone gave the workaround 'history -a; history -r' to be able
to reliably obtain [in bash] the actual history image. (Ksh's history,
for example, doesn't seem to require such workarounds.)

Janis

Re: capture the maximum amount of cmd history in bash

<eli$2203232051@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5181&group=comp.unix.shell#5181

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Thu, 24 Mar 2022 00:53:14 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2203232051@qaz.wtf>
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me> <eli$2203221321@qaz.wtf> <t1fkji$vnf$1@dont-email.me>
Injection-Date: Thu, 24 Mar 2022 00:53:14 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="17621"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Thu, 24 Mar 2022 00:53 UTC

In comp.unix.shell, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
> On 22.03.2022 18:39, Eli the Bearded wrote:
>> PROMPT_COMMAND='history -a >(logger -t "user $(id -u); at $(date +%s); in ${PWD}"'
>>
>> Then ensure logs are sent off-system.
>
> I'm not sure whether that's a solution for the history, typed commands
> to be easily retrieved for re-running them or re-running them edited.
> A logger's purpose is different to a shell history's purpose, isn't
> it?

Pretty sure the question was about saving history, not re-running it. :^)

The history-to-logger command above was from an emergency shellhost. The
idea is to assist in logging what was done when responding to system
emergencies for the incident report. I'll interject comments via 'echo'
when using that sort of thing.

echo restarting foo on advice of Bar
aws ec2 restart-instance...

I do that in `script` session logging, too.

Elijah
------
and will use ex or ed when it helps for logging

Re: capture the maximum amount of cmd history in bash

<87a6db8imv.fsf@local.lan>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5195&group=comp.unix.shell#5195

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx41.iad.POSTED!not-for-mail
From: hpu...@zohomail.com (hput)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Message-ID: <87a6db8imv.fsf@local.lan>
Cancel-Lock: sha1:qNSmRHlPb4eAJqEj609DuH1CyJo=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 83
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 27 Mar 2022 12:28:24 -0400
X-Received-Bytes: 3825
 by: hput - Sun, 27 Mar 2022 16:28 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> On 22.03.2022 16:25, hput wrote:
>> Can anyone post some examples of how to setup bash configuration
>> files to capture the maximum amount of command history.
>
> What do you mean by that?
>
> Capture the actual contents? Then use: fc -l 1
>
> Or make history memory for shell windows as large as possible?
>
> You can define any size by setting the HISTSIZE variable, as in
>
> HISTSIZE=1000000

I only meant that all commands issued in the bash shells that I use
via xterm end up in ~/.bash_history

My history related settings in .bashrc which I should have included
in OP
------- ------- ---=--- ------- -------
# [HP 101709_135944 BEGIN All HISTORY variablesT
HISTIGNORE='ls:cd:clear:fg:exit';export HISTIGNORE
HISTCONTROL='ignoreboth';export HISTCONTROL
HISTSIZE='30000';export HISTSIZE
HISTFILESIZE='100000';export HISTFILESIZE
HISTFILE=~/.bash_history;export HISTFILE

shopt -s histappend
## PROMPT_COMMAND="$PROMPT_COMMAND;history -a" ; export PROMPT_COMMAND
## END ALL HISTORY variables ]
------- ------- ---=--- ------- -------

I'm not sure how to set up the PROMPT_COMMAND line. Somewhere in this
thread has been suggested adding the -r flag to PROMPT_COMMAND. What
effect does that have?

Its commented because at one point something I did to that section
caused Whole PROMPT_COMMAND setup to appear at the end of output every
time I ran something in a shell. So I hoped to get an idea how to set
that up so that all cmds end up in ~/.bash_history

Not sure what is supposed to happen to its accumulated history if an
xterm running bash is killed or crashes somehow.

Or what happens if the ~/.bash_history ever reaches $HISTFILESIZE.

Thinking about how to save that file some how automatically.
Something like how logrotate works would be handy where
~/.bash_history would be rotated by size limit, to as many rotated
versions as I like.

> Since the history will be stored in a file (or maybe temporarily in
> memory depending on shell), the limit is basically a runtime limit,
> depending on your (available and used) system resources.
>
>> When, even
>> though it is a single user host, often, multiple shells come into
>> play.

[...] snipped helpful commentary

> TTY=$( tty )
> TTY=${TTY#/dev/}
> TTY=${TTY//\//_}
> export HISTFILE=${HOME}/.sh_history_${TTY}
> export HISTSIZE=1000
>
> to create history files named individually for each shell window.

Do you then add them to some accumulative file?

It must be clear to all that I need to study up on the whole topic of
shell history.

Can anyone offer some guidance on where I might find examples of
settings effecting the accumulation of shell history and a thorough
write up of how it all is supposed to work?

The coverage in man bash is pretty slim, and entirely devoid of
example settings. Especially anything about the workings of
PROMPT_COMMAND.

Re: capture the maximum amount of cmd history in bash

<eli$2203281637@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5198&group=comp.unix.shell#5198

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: capture the maximum amount of cmd history in bash
Date: Mon, 28 Mar 2022 20:45:36 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2203281637@qaz.wtf>
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me> <87a6db8imv.fsf@local.lan>
Injection-Date: Mon, 28 Mar 2022 20:45:36 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="8234"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Mon, 28 Mar 2022 20:45 UTC

In comp.unix.shell, hput <hputn3@zohomail.com> wrote:
> I'm not sure how to set up the PROMPT_COMMAND line. Somewhere in this
> thread has been suggested adding the -r flag to PROMPT_COMMAND. What
> effect does that have?

PROMPT_COMMAND is a variable. The command in the variabke is run by the
shell just prior to each PS1 display.

The -r was given to the 'history' bash built in command. It refreshes in
shell history with contents of history file each time. This presumably
helps if you have multiple shelks writing to the same history file.
(That is not my usual style.)

Elijah
------
one history file per tty

I'm curious; how do you do it? (Was: capture the maximum amount of cmd history in bash)

<t1t9di$27kcr$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5199&group=comp.unix.shell#5199

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: I'm curious; how do you do it? (Was: capture the maximum amount of cmd history in bash)
Date: Mon, 28 Mar 2022 21:30:26 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t1t9di$27kcr$1@news.xmission.com>
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me> <87a6db8imv.fsf@local.lan> <eli$2203281637@qaz.wtf>
Injection-Date: Mon, 28 Mar 2022 21:30:26 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2347419"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 28 Mar 2022 21:30 UTC

In article <eli$2203281637@qaz.wtf>,
Eli the Bearded <*@eli.users.panix.com> wrote:
....
>... if you have multiple shelks writing to the same history file.
>(That is not my usual style.)
>
>Elijah
>------
>one history file per tty

What is your implementation for that?

I'd like to see it and to compare it to my own.

--
They say compassion is a virtue, but I don't have the time!

- David Byrne -

Re: I'm curious; how do you do it? (Was: capture the maximum amount of cmd history in bash)

<eli$2203281921@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5200&group=comp.unix.shell#5200

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: I'm curious; how do you do it? (Was: capture the maximum amount of cmd history in bash)
Date: Mon, 28 Mar 2022 23:29:45 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2203281921@qaz.wtf>
References: <87czie6mbm.fsf@local.lan> <87a6db8imv.fsf@local.lan> <eli$2203281637@qaz.wtf> <t1t9di$27kcr$1@news.xmission.com>
Injection-Date: Mon, 28 Mar 2022 23:29:45 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="24435"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Mon, 28 Mar 2022 23:29 UTC

In comp.unix.shell, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> Eli the Bearded <*@eli.users.panix.com> wrote:
>> one history file per tty
> What is your implementation for that?

tty=`tty || :`
....
HISTFILE=$HOME/.kshrc_history.${tty##*/}

Obviously from that, ksh is my preferred shell. I don't think I've
edited those lines in fifteen years. $() is my usual notation now.

Elijah
------
probably did something causing 'not a tty' errors for that first part

Re: I'm curious; how do you do it? (Was: capture the maximum amount of cmd history in bash)

<op.1jrr19g6a3w0dxdave@hodgins.homeip.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5201&group=comp.unix.shell#5201

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: I'm curious; how do you do it? (Was: capture the maximum amount
of cmd history in bash)
Date: Mon, 28 Mar 2022 22:04:47 -0400
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <op.1jrr19g6a3w0dxdave@hodgins.homeip.net>
References: <87czie6mbm.fsf@local.lan> <87a6db8imv.fsf@local.lan>
<eli$2203281637@qaz.wtf> <t1t9di$27kcr$1@news.xmission.com>
<eli$2203281921@qaz.wtf>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="fe33a5b970b10f60ff535a885155e69a";
logging-data="14276"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Iq5hocojHtC98ZiH3Aj7zZL5zOETcJmQ="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:+iT7UovN3XnZgWNpDxGkAZL8xfM=
 by: David W. Hodgins - Tue, 29 Mar 2022 02:04 UTC

On Mon, 28 Mar 2022 19:29:45 -0400, Eli the Bearded <*@eli.users.panix.com> wrote:
> In comp.unix.shell, Kenny McCormack <gazelle@shell.xmission.com> wrote:
>> Eli the Bearded <*@eli.users.panix.com> wrote:
>>> one history file per tty
>> What is your implementation for that?
>
> tty=`tty || :`
> ...
> HISTFILE=$HOME/.kshrc_history.${tty##*/}
>
> Obviously from that, ksh is my preferred shell. I don't think I've
> edited those lines in fifteen years. $() is my usual notation now.
>
> Elijah
> ------
> probably did something causing 'not a tty' errors for that first part

Thanks! Added the following line to my ~/.bashrc file ...
tty="$(tty || :)" HISTFILE="$HISTFILE"".${tty##*/}"

I now get .bash_history.1 for a konsole terminal, and .bash_history.tty5 after
using alt+ctrl+f5 to switch to a pty.

I doubt the || : is needed as .bashrc is only used in interactive shells, but
it doesn't do any harm.

Regards, Dave Hodgins

Re: capture the maximum amount of cmd history in bash

<wLOdnUlO_uJf9N__nZ2dnUU7-XfNnZ2d@brightview.co.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5202&group=comp.unix.shell#5202

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 28 Mar 2022 21:06:58 -0500
From: inva...@invalid.invalid (Javier)
Subject: Re: capture the maximum amount of cmd history in bash
Newsgroups: comp.unix.shell
References: <87czie6mbm.fsf@local.lan> <t1cts6$p7d$1@dont-email.me> <87a6db8imv.fsf@local.lan>
Message-ID: <wLOdnUlO_uJf9N__nZ2dnUU7-XfNnZ2d@brightview.co.uk>
Date: Mon, 28 Mar 2022 21:06:58 -0500
Lines: 15
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-wZdvE0Z9dEHjsZ0tGWKLPkqS9CqPvqg5VbHnWRQ8AJPqHA3lpFN7ZdnLH77ux0vo4GQxpZNg7+0nsvU!lQYqtBrqFsFy6gWAZMHG99TNR5FctHJIaVDwIHw/TGnn9+1gd+Vlt4Jfu0o1vkidqgjh/S+DAhmQ!4A6oFIKa3sxLPSm8n8LepA+YrBs=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1556
 by: Javier - Tue, 29 Mar 2022 02:06 UTC

hput <hputn3@zohomail.com> wrote:
> Not sure what is supposed to happen to its accumulated history if an
> xterm running bash is killed or crashes somehow.

Even if xterm crashes, or is killed with signal 9 SIGKILL, the child
process running bash will receive SIGHUP (hang up), and receiving SIGHUP
bash will write its history normally as if it was terminated by typing exit.

To really stop the shell from saving its history you need to send
SIGKILL to the shell on purpose. For example you can kill the current
shell process by typing

kill -9 $$

In that case, the history of that shell process would be lost.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor