Bash: "history number" vs "command number"
As far as I can tell (and this seems confirmed by your research), there is no way to refer to that magic number interactively, or not through fc
or !n
shortcuts. Those certainly seem to refer only to the absolute position in the history list, not the relative position since this specific shell started (which is waht \#
refers to, as you correctly pointed out).
The only way i found to make this nicer here is to set the following:
export HISTFILESIZE=1001
export HISTSIZE=-1
That way:
- a new session's history starts at
1000
, which makes it easier to identify where i'm at in a session - (somewhat unrelated) i don't lose older history in a given session (but still don't flood the file)
Basically, it turned my modified prompt (PS1="\\!$ "
) from:
499$
to:
1000$
... which makes it a little cleaner on start. But that's probably not the answer you were looking for. :)
(By the way, I also looked at zsh for a solution, and it seems it simply doesn't have the equivalent of \#
, so that doesn't help at all either.)