Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Q: How much does it cost to ride the Unibus? A: 2 bits.


comp / comp.unix.shell / Re: [ksh] Show command number in shell prompt

SubjectAuthor
* [ksh] Show command number in shell promptJanis Papanagnou
`* Re: [ksh] Show command number in shell prompthymie!
 `* Re: [ksh] Show command number in shell promptJanis Papanagnou
  +* Re: [ksh] Show command number in shell prompthymie!
  |+- Re: [ksh] Show command number in shell promptJanis Papanagnou
  |`* Re: [ksh] Show command number in shell promptKeith Thompson
  | `* Re: [ksh] Show command number in shell promptKeith Thompson
  |  `- Re: [ksh] Show command number in shell promptJanis Papanagnou
  `* Re: [ksh] Show command number in shell promptLawrence D'Oliveiro
   +* Re: [ksh] Show command number in shell promptKeith Thompson
   |`- Re: [ksh] Show command number in shell promptKaz Kylheku
   `* Re: [ksh] Show command number in shell promptJanis Papanagnou
    `* Re: [ksh] Show command number in shell promptKees Nuyt
     `* Re: [ksh] Show command number in shell promptJanis Papanagnou
      `- Re: [ksh] Show command number in shell promptChristian Weisgerber

1
Subject: [ksh] Show command number in shell prompt
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 12:45 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 14:45:46 +0200
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <vcuc9r$373il$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Sep 2024 14:45:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2840717624f99e06c1a845f4f7da582e";
logging-data="3378773"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JFxlPrnNIeKEsNy28BTRc"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:JrIqJK6EyeRAcnjjk4pCy9mq9Mc=
X-Enigmail-Draft-Status: N1110
X-Mozilla-News-Host: news://news.eternal-september.org:119
View all headers

Not long ago I added an '!' (exclamation mark) to my prompt to have
it get expanded to the command number [in Kornshell]; PS1='(!)$ '
The effect is that a new shell instance starts with the number 1000
which incidentally equals the HISTSIZE. - Any ideas what could have
gone wrong here?

Janis

Subject: Re: [ksh] Show command number in shell prompt
From: hymie!
Newsgroups: comp.unix.shell
Organization: Eric Conspiracy Secret Labs
Date: Tue, 24 Sep 2024 12:59 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
Newsgroups: comp.unix.shell
From: hymie@nasalinux.net (hymie!)
Subject: Re: [ksh] Show command number in shell prompt
References: <vcuc9r$373il$1@dont-email.me>
Organization: Eric Conspiracy Secret Labs
User-Agent: slrn/pre1.0.4-6 (Linux)
Message-ID: <slrnvf5dsq.2b4.hymie@nasalinux.net>
Lines: 18
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Tue, 24 Sep 2024 12:59:06 UTC
Date: Tue, 24 Sep 2024 12:59:06 GMT
X-Received-Bytes: 1338
View all headers

In our last episode, the evil Dr. Lacto had captured our hero,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com>, who said:
> Not long ago I added an '!' (exclamation mark) to my prompt to have
> it get expanded to the command number [in Kornshell]; PS1='(!)$ '
> The effect is that a new shell instance starts with the number 1000
> which incidentally equals the HISTSIZE. - Any ideas what could have
> gone wrong here?

Nothing has gone wrong.

HISTSIZE=1000 means that the maximum size of your history is 1000. Once it
hits that level, the oldest entries are dropped, and the newest entries
are added to the end.

So every command you issue is always the last command in the history.
Since the history is full, it's always command number 1000.

--hymie! http://nasalinux.net/~hymie hymie@nasalinux.net

Subject: Re: [ksh] Show command number in shell prompt
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 13:23 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 15:23:56 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <vcuehc$37dtm$1@dont-email.me>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Sep 2024 15:23:57 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2840717624f99e06c1a845f4f7da582e";
logging-data="3389366"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oBnBzpJ0ojF4L3b07FEU0"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:KMhQEWOB0qiSg9B6TaY493J8cyM=
In-Reply-To: <slrnvf5dsq.2b4.hymie@nasalinux.net>
X-Enigmail-Draft-Status: N1110
View all headers

On 24.09.2024 14:59, hymie! wrote:
> In our last episode, the evil Dr. Lacto had captured our hero,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com>, who said:
>> Not long ago I added an '!' (exclamation mark) to my prompt to have
>> it get expanded to the command number [in Kornshell]; PS1='(!)$ '
>> The effect is that a new shell instance starts with the number 1000
>> which incidentally equals the HISTSIZE. - Any ideas what could have
>> gone wrong here?
>
> Nothing has gone wrong.
>
> HISTSIZE=1000 means that the maximum size of your history is 1000. Once it
> hits that level, the oldest entries are dropped, and the newest entries
> are added to the end.
>
> So every command you issue is always the last command in the history.
> Since the history is full, it's always command number 1000.

Hmm.. - that explains, maybe, part of it. Thanks.

I'm still irritated; if I see in one shell session a value of 11059
(which is an indication that the numbers created by '!' don't wrap)
I'm astonished that the counting in a new window will start at 1000
(and not at 1 or at the maximum previous value).

I've just closed a window with an actual maximum command number of
1643, and "restoring"[*] that window will continue at 1643.

Still puzzling...

Janis

[*] Note: Closing a shell window and re-opening it anew will work
on the previous, same history file.

Subject: Re: [ksh] Show command number in shell prompt
From: hymie!
Newsgroups: comp.unix.shell
Organization: Eric Conspiracy Secret Labs
Date: Tue, 24 Sep 2024 17:40 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx14.iad.POSTED!not-for-mail
Newsgroups: comp.unix.shell
From: hymie@nasalinux.net (hymie!)
Subject: Re: [ksh] Show command number in shell prompt
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
Organization: Eric Conspiracy Secret Labs
User-Agent: slrn/pre1.0.4-6 (Linux)
Message-ID: <slrnvf5ubh.3d2.hymie@nasalinux.net>
Lines: 40
X-Complaints-To: abuse@usenet-news.net
NNTP-Posting-Date: Tue, 24 Sep 2024 17:40:01 UTC
Date: Tue, 24 Sep 2024 17:40:01 GMT
X-Received-Bytes: 2451
View all headers

In our last episode, the evil Dr. Lacto had captured our hero,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com>, who said:
> On 24.09.2024 14:59, hymie! wrote:
>> In our last episode, the evil Dr. Lacto had captured our hero,
>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com>, who said:
>>> Not long ago I added an '!' (exclamation mark) to my prompt to have
>>> it get expanded to the command number [in Kornshell]; PS1='(!)$ '
>>> The effect is that a new shell instance starts with the number 1000
>>> which incidentally equals the HISTSIZE. - Any ideas what could have
>>> gone wrong here?
>>
>> Nothing has gone wrong.
>>
>> HISTSIZE=1000 means that the maximum size of your history is 1000. Once it
>> hits that level, the oldest entries are dropped, and the newest entries
>> are added to the end.
>>
>> So every command you issue is always the last command in the history.
>> Since the history is full, it's always command number 1000.
>
> Hmm.. - that explains, maybe, part of it. Thanks.
>
> I'm still irritated; if I see in one shell session a value of 11059
> (which is an indication that the numbers created by '!' don't wrap)
> I'm astonished that the counting in a new window will start at 1000
> (and not at 1 or at the maximum previous value).

I don't use this feature, and I don't have ksh, just bash and zsh.
Bash has separate options for

\! the history number of this command
\# the command number of this command

I don't know what your goal is, but maybe ksh has these two options, and you
want the other one?

For the record, every time I open a bash shell, \! starts at 51 (HISTSIZE + 1)
and \# starts at 1.

--hymie! http://nasalinux.net/~hymie hymie@nasalinux.net

Subject: Re: [ksh] Show command number in shell prompt
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 19:56 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 21:56:13 +0200
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <vcv5gu$3atig$1@dont-email.me>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<slrnvf5ubh.3d2.hymie@nasalinux.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 24 Sep 2024 21:56:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2840717624f99e06c1a845f4f7da582e";
logging-data="3503696"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UwqLwqkoWihYGdQmlRfLK"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Ivao0SCZ559KM/oewI8tOX1Cb8M=
In-Reply-To: <slrnvf5ubh.3d2.hymie@nasalinux.net>
X-Enigmail-Draft-Status: N1110
View all headers

On 24.09.2024 19:40, hymie! wrote:
>>
>> I'm still irritated; if I see in one shell session a value of 11059
>> (which is an indication that the numbers created by '!' don't wrap)
>> I'm astonished that the counting in a new window will start at 1000
>> (and not at 1 or at the maximum previous value).
>
> I don't use this feature, and I don't have ksh, just bash and zsh.
> Bash has separate options for
>
> \! the history number of this command
> \# the command number of this command
>
> I don't know what your goal is, but maybe ksh has these two options, and you
> want the other one?

In ksh I know only of '!', a single unquoted literal exclamation mark.

But never mind. - My goal was just to not constantly see in my shell
instances what appears to me to look like an inconsistency. - Another
(bash-)prompt posting inspired me to post. But I also know only few
folks use ksh nowadays, most use bash, so I didn't really expect any
"solution" (sort of). Functionally there's no apparent drawback, so I
can live with it. Thanks.

Janis

Subject: Re: [ksh] Show command number in shell prompt
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Tue, 24 Sep 2024 20:01 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 13:01:47 -0700
Organization: None to speak of
Lines: 51
Message-ID: <87jzf0q0r8.fsf@nosuchdomain.example.com>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<slrnvf5ubh.3d2.hymie@nasalinux.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Tue, 24 Sep 2024 22:01:47 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cfe9758cda96ae01dcefed05ed131451";
logging-data="3495475"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MV0gIDHoV68n6XBQR+VVp"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:VCtug+nanoMMGZmUoDLfmZcqwfk=
sha1:CdiHy5/QeqnrQIYktYBFJh24llg=
View all headers

hymie! <hymie@nasalinux.net> writes:
> In our last episode, the evil Dr. Lacto had captured our hero,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com>, who said:
>> On 24.09.2024 14:59, hymie! wrote:
>>> In our last episode, the evil Dr. Lacto had captured our hero,
>>> Janis Papanagnou <janis_papanagnou+ng@hotmail.com>, who said:
>>>> Not long ago I added an '!' (exclamation mark) to my prompt to have
>>>> it get expanded to the command number [in Kornshell]; PS1='(!)$ '
>>>> The effect is that a new shell instance starts with the number 1000
>>>> which incidentally equals the HISTSIZE. - Any ideas what could have
>>>> gone wrong here?
>>>
>>> Nothing has gone wrong.
>>>
>>> HISTSIZE=1000 means that the maximum size of your history is 1000. Once it
>>> hits that level, the oldest entries are dropped, and the newest entries
>>> are added to the end.
>>>
>>> So every command you issue is always the last command in the history.
>>> Since the history is full, it's always command number 1000.
>>
>> Hmm.. - that explains, maybe, part of it. Thanks.
>>
>> I'm still irritated; if I see in one shell session a value of 11059
>> (which is an indication that the numbers created by '!' don't wrap)
>> I'm astonished that the counting in a new window will start at 1000
>> (and not at 1 or at the maximum previous value).
>
> I don't use this feature, and I don't have ksh, just bash and zsh.
> Bash has separate options for
>
> \! the history number of this command
> \# the command number of this command
>
> I don't know what your goal is, but maybe ksh has these two options, and you
> want the other one?
>
> For the record, every time I open a bash shell, \! starts at 51 (HISTSIZE + 1)
> and \# starts at 1.

If you use numbered history references, they refer to the history
number, not the command number. For example, !25 will execute the 25th
command from your history. This could be confusing if you show the
command number in $PS1.

I didn't know about \# until just now. I've just updated my .bashrc to
put "\#/\!" in my $PS1. I suspect I won't find it useful.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: [ksh] Show command number in shell prompt
From: Lawrence D'Oliv
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 21:31 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 21:31:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <vcvb3k$3bcrt$11@dont-email.me>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Sep 2024 23:31:33 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="674280cc33f5e0467b40694e2ad610e4";
logging-data="3519357"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SrOwNwdDF6B3m9hfBIskU"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:xqeqt53c7G0Y+2WSckdc9f5JM1s=
View all headers

On Tue, 24 Sep 2024 15:23:56 +0200, Janis Papanagnou wrote:

> [*] Note: Closing a shell window and re-opening it anew will work on the
> previous, same history file.

I typically have over a dozen shell windows open at a time. They would all
happily clobber the same history file, which somewhat limits its use for
me.

Subject: Re: [ksh] Show command number in shell prompt
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Tue, 24 Sep 2024 22:28 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 15:28:03 -0700
Organization: None to speak of
Lines: 16
Message-ID: <87a5fwptzg.fsf@nosuchdomain.example.com>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<vcvb3k$3bcrt$11@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 25 Sep 2024 00:28:04 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a275b4717ac7daeba95e5bb65b4a0563";
logging-data="3543739"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19eQe0UYvIwn96I7yDbBxhg"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:eXGoNIFpc8bk4UjQlqZBUZhcYHk=
sha1:4GHKG0xZ755PJIKFw8BN1asULmQ=
View all headers

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Tue, 24 Sep 2024 15:23:56 +0200, Janis Papanagnou wrote:
>> [*] Note: Closing a shell window and re-opening it anew will work on the
>> previous, same history file.
>
> I typically have over a dozen shell windows open at a time. They would all
> happily clobber the same history file, which somewhat limits its use for
> me.

Using a different $HISTFILE for each shell avoids that. I assign
consistent names to shell windows, under tmux, and I construct $HISTFILE
from the name.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: [ksh] Show command number in shell prompt
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 22:41 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Wed, 25 Sep 2024 00:41:21 +0200
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <vcvf6i$3cb0q$1@dont-email.me>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<vcvb3k$3bcrt$11@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 25 Sep 2024 00:41:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6e2543cf8c9b2e66e4308309d2643294";
logging-data="3550234"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187k3VMcoPcVZ++gAyUjZl1"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:HhqPyP6khuHpWUoDKhYY3t00q6U=
In-Reply-To: <vcvb3k$3bcrt$11@dont-email.me>
View all headers

On 24.09.2024 23:31, Lawrence D'Oliveiro wrote:
> On Tue, 24 Sep 2024 15:23:56 +0200, Janis Papanagnou wrote:
>
>> [*] Note: Closing a shell window and re-opening it anew will work on the
>> previous, same history file.
>
> I typically have over a dozen shell windows open at a time. They would all
> happily clobber the same history file, which somewhat limits its use for
> me.

Of course I have a more complex setup that uses an own history file
per "window"; I use for example a name like ".sh_history_pts_57"
(using 'HISTFILE').

I have yet more functions associated, e.g. a "CWD" or a window title
per "window", etc., to be able to keep and restore yet more context.

Janis

Subject: Re: [ksh] Show command number in shell prompt
From: Kaz Kylheku
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 22:53 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 22:53:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <20240924153833.173@kylheku.com>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<vcvb3k$3bcrt$11@dont-email.me> <87a5fwptzg.fsf@nosuchdomain.example.com>
Injection-Date: Wed, 25 Sep 2024 00:53:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3108cceea72fe57d58a2aaa356503884";
logging-data="3548812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kiiJuSJOp82Pin5NdLB9YhbY6C9sThs4="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:FKqAr8qQOxe1vUwbl+eI0yUeDyg=
View all headers

On 2024-09-24, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>> On Tue, 24 Sep 2024 15:23:56 +0200, Janis Papanagnou wrote:
>>> [*] Note: Closing a shell window and re-opening it anew will work on the
>>> previous, same history file.
>>
>> I typically have over a dozen shell windows open at a time. They would all
>> happily clobber the same history file, which somewhat limits its use for
>> me.
>
> Using a different $HISTFILE for each shell avoids that. I assign
> consistent names to shell windows, under tmux, and I construct $HISTFILE
> from the name.

In the TXR Lisp listener, I implemented an incredible idea from the
far future: on exit, it combines the to-be-saved history with new
material that may have appeared in the history file by the termination
of a parallel session.

The algorithm is

1. Load the existing history (using a new, shadow instance of the
listener object), and save it to a temporary file, trimming the
amount of history to the currently configured limit.

2. Append to that temporary file all the new lines from the
current session.

3. Rename the temporary file to the real history file name.

There is no locking: don't be somehow exiting your interactive sessions
simultaneously.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: [ksh] Show command number in shell prompt
From: Keith Thompson
Newsgroups: comp.unix.shell
Organization: None to speak of
Date: Tue, 24 Sep 2024 23:35 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Tue, 24 Sep 2024 16:35:33 -0700
Organization: None to speak of
Lines: 17
Message-ID: <875xqkpquy.fsf@nosuchdomain.example.com>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<slrnvf5ubh.3d2.hymie@nasalinux.net>
<87jzf0q0r8.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 25 Sep 2024 01:35:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a275b4717ac7daeba95e5bb65b4a0563";
logging-data="3564206"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+i1hTmFxtN8B3utjBY2v1M"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:/XlUO6+ea7fgCpGAdhvqYd+w0JQ=
sha1:NDYpkvffOH9p9V+z3LZGtkasiEk=
View all headers

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
[...]
> If you use numbered history references, they refer to the history
> number, not the command number. For example, !25 will execute the 25th
> command from your history. This could be confusing if you show the
> command number in $PS1.

And of course the "history" command shows history numbers, not command
numbers.

The command number doesn't seem to be used for anything other than
showing the number of commands issued in the current shell process.
(Personally, I don't find the command number to be useful information.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: [ksh] Show command number in shell prompt
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Wed, 25 Sep 2024 00:24 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Wed, 25 Sep 2024 02:24:02 +0200
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <vcvl72$3d38m$1@dont-email.me>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<slrnvf5ubh.3d2.hymie@nasalinux.net>
<87jzf0q0r8.fsf@nosuchdomain.example.com>
<875xqkpquy.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 25 Sep 2024 02:24:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="6e2543cf8c9b2e66e4308309d2643294";
logging-data="3575062"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18c2EkyX+PMMnYjRRfZkuOT"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:X49yAtT8qfh4JR5PqJXbXfg2/7U=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <875xqkpquy.fsf@nosuchdomain.example.com>
View all headers

On 25.09.2024 01:35, Keith Thompson wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> [...]
>> If you use numbered history references, they refer to the history
>> number, not the command number. For example, !25 will execute the 25th
>> command from your history. This could be confusing if you show the
>> command number in $PS1.
>
> And of course the "history" command shows history numbers, not command
> numbers.
>
> The command number doesn't seem to be used for anything other than
> showing the number of commands issued in the current shell process.
> (Personally, I don't find the command number to be useful information.)

Terminology obviously varies; ksh speaks only about "command number"
and refers to it as '!' in the prompt, and all the history commands
(or aliases), fc, hist, history, speak only about "command numbers".

So bash's "history numbers" ('\!') are the equivalent of ksh's
"command numbers" ('!') - a potential source of confusion?

BTW: POSIX 'fc' speaks also about "reference commands by number".

Bash's explanation:
"The command number and the history number are usually different: the
history number of a command is its position in the history list, which
may include commands restored from the history file (see HISTORY
below), while the command number is the position in the sequence of
commands executed during the current shell session."

Hmm...

Janis

Subject: Re: [ksh] Show command number in shell prompt
From: Kees Nuyt
Newsgroups: comp.unix.shell
Organization: KPN B.V.
Date: Wed, 25 Sep 2024 22:26 UTC
References: 1 2 3 4 5
From: k.nuyt@nospam.demon.nl (Kees Nuyt)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Thu, 26 Sep 2024 00:26:07 +0200
Reply-To: k.nuyt@nospam.demon.nl
Message-ID: <q039fj56mf7m969scdjq3aqhf0s1sqcadj@dim53.demon.nl>
References: <vcuc9r$373il$1@dont-email.me> <slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me> <vcvb3k$3bcrt$11@dont-email.me> <vcvf6i$3cb0q$1@dont-email.me>
User-Agent: ForteAgent/7.10.32.1214
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Organization: KPN B.V.
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.mixmin.net!news.neodome.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe007.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 38
Injection-Date: Thu, 26 Sep 2024 00:26:08 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 1855
View all headers

On Wed, 25 Sep 2024 00:41:21 +0200, Janis Papanagnou
<janis_papanagnou+ng@hotmail.com> wrote:

> Of course I have a more complex setup that uses an own history file
> per "window"; I use for example a name like ".sh_history_pts_57"
> (using 'HISTFILE').

I do that per "project"

To switch projects, I source a bash script which ends like this:

:
[... project selection code here ...]
: # r is the return code of some project selection
# code (some whiptail involved)
# b is the base directory for all projects
# c is the project subdirectory
#
if [ $r -eq 0 ] && [ -n "$c" ] && [ -d "${b}/${c}" ]
then
history -a # save hist of previous project
history -c # clear hist cache
cd "${b}/${c}" || exit 9
ls -lA
test -d bin && PATH=./bin:$(echo $PATH \
| sed -e 's@\./bin:@@')
test -f .fslckout && fossil status
test -f .fslckout && fossil stash list --verbose
HISTFILE=${PWD}/.bash_history
history -r # read any existing hist of this project
unset b c r
fi

--
Kees Nuyt

Subject: Re: [ksh] Show command number in shell prompt
From: Janis Papanagnou
Newsgroups: comp.unix.shell
Organization: A noiseless patient Spider
Date: Thu, 26 Sep 2024 12:21 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Thu, 26 Sep 2024 14:21:31 +0200
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <vd3jkc$67l1$1@dont-email.me>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<vcvb3k$3bcrt$11@dont-email.me> <vcvf6i$3cb0q$1@dont-email.me>
<q039fj56mf7m969scdjq3aqhf0s1sqcadj@dim53.demon.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 26 Sep 2024 14:21:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2605737c97ff88ac87e773da595ceb0b";
logging-data="204449"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Pmn8xfMjXjKwc4TBYyr6s"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:YfiToGQOOZTU8zJWRcqmHm3vq8M=
In-Reply-To: <q039fj56mf7m969scdjq3aqhf0s1sqcadj@dim53.demon.nl>
View all headers

On 26.09.2024 00:26, Kees Nuyt wrote:
> On Wed, 25 Sep 2024 00:41:21 +0200, Janis Papanagnou
> <janis_papanagnou+ng@hotmail.com> wrote:
>
>> Of course I have a more complex setup that uses an own history file
>> per "window"; I use for example a name like ".sh_history_pts_57"
>> (using 'HISTFILE').
>
> I do that per "project"

My "windows" are actually also dedicated to "projects", where every
project typically uses 1..3 shell terminals.

>
> To switch projects, I source a bash script which ends like this:
> [...]
> test -f .fslckout && fossil status
> test -f .fslckout && fossil stash list --verbose
> [...]

What is 'fossil'?

Janis

Subject: Re: [ksh] Show command number in shell prompt
From: Christian Weisgerber
Newsgroups: comp.unix.shell
Date: Thu, 26 Sep 2024 15:32 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: naddy@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: [ksh] Show command number in shell prompt
Date: Thu, 26 Sep 2024 15:32:48 -0000 (UTC)
Message-ID: <slrnvfavl0.hnf.naddy@lorvorc.mips.inka.de>
References: <vcuc9r$373il$1@dont-email.me>
<slrnvf5dsq.2b4.hymie@nasalinux.net> <vcuehc$37dtm$1@dont-email.me>
<vcvb3k$3bcrt$11@dont-email.me> <vcvf6i$3cb0q$1@dont-email.me>
<q039fj56mf7m969scdjq3aqhf0s1sqcadj@dim53.demon.nl>
<vd3jkc$67l1$1@dont-email.me>
Injection-Date: Thu, 26 Sep 2024 15:32:48 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="18160"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
View all headers

On 2024-09-26, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

>> test -f .fslckout && fossil status
>> test -f .fslckout && fossil stash list --verbose
>
> What is 'fossil'?

A version control system, pardon, software configuration management
system:
https://fossil-scm.org/

--
Christian "naddy" Weisgerber naddy@mips.inka.de

1

rocksolid light 0.9.8
clearnet tor