Janis Papanagnou <
janis_pa...@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.