Is there a way to set the size of the history list in bash to more than 5000 lines?
This is the actual code that loads the history (from bashhist.c
around line 260):
/* Load the history list from the history file. */
void
load_history ()
{
char *hf;
/* Truncate history file for interactive shells which desire it.
Note that the history file is automatically truncated to the
size of HISTSIZE if the user does not explicitly set the size
differently. */
set_if_not ("HISTSIZE", "500");
sv_histsize ("HISTSIZE");
set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE"));
sv_histsize ("HISTFILESIZE");
/* Read the history in HISTFILE into the history list. */
hf = get_string_value ("HISTFILE");
if (hf && *hf && file_exists (hf))
{
read_history (hf);
using_history ();
history_lines_in_file = where_history ();
}
}
If the values of HISTSIZE
and HISTFILESIZE
are set, they will be used.
Readline, the library that actually handles input / line editing and history does offer facilities to put a cap on just how big the history buffer can grow. However, Bash does not place a hard ceiling on this where values any larger would be ignored, at least that I could find.
Edit
From comments, readline
was indeed the culprit. I was looking (rather foolishly) at functional parameters:
there is a variable called history-size that can be read from the inputrc file. that variable sets the maximum number of history entries saved in the history list. I checked it's value in my local inputrc file to found it equal 5000. Setting it to a larger value solved the problem.
Your history is truncated the first time HISTSIZE is set, so if it's set to 5000 earlier in your ~/.bashrc, or in the system-wide bashrc in /etc, you need to comment those out.
Try both HISTFILESIZE
and HISTSIZE
.