.bash_profile
is only loaded if bash is started as a login shell. On OSX, the default is to start a login shell in every terminal, so that's the common case for you. But if you ever type bash
to run a nested shell, or run screen or tmux, or anything else that starts an interactive shell, you'll end up with an interactive, non-login shell. This shell only reads ~/.bashrc
, it doesn't read ~/.bash_profile
. Since you exported HISTFILESIZE
to the environment, a shell that's started from a program started from a terminal that ran a login shell will inherit that setting. But a shell started independently will not (which is a fundamental flaw in OSX's approach of starting login shells in terminals.) So a shell started inside a terminal emulator that doesn't start a login shell, or in a screen session started by a cron job, or in Aquamacs, etc. won't have any HISTSIZE
or HISTFILESIZE
setting and thus will use the default values.
The fix is to set HISTSIZE
and HISTFILESIZE
at the proper place: in ~/.bashrc
.
Bash bizarrely reads .bashrc
only from non-login interactive shells. To get it read in all interactive shells, put the following line in your .bash_profile
:
case $- in *i*) . ~/.bashrc;; esac
.bash_profile
instead of.bashrc
which wasn't my problem. – DisplayName Nov 27 '14 at 17:14.profile
. – cuonglm Nov 27 '14 at 17:17echo $HISTSIZE
? – Sreeraj Nov 27 '14 at 18:05$dosifnsdoifjoisdjfisodf
would. – DisplayName Nov 27 '14 at 18:10