Sujet : Re: [ksh] Show command number in shell prompt
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.unix.shellDate : 24. Sep 2024, 22:01:47
Autres entêtes
Organisation : None to speak of
Message-ID : <87jzf0q0r8.fsf@nosuchdomain.example.com>
References : 1 2 3 4
User-Agent : Gnus/5.13 (Gnus v5.13)
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.comvoid Void(void) { Void(); } /* The recursive call of the void */