Bash doesn't write history

Viewed 335

i tried to read other similar posts but i couldn't find any solution. I'm using a Mac with Iterm and as my title my bash doesn't write the history.

here my tests:

echo $HISTFILE
/Users/myname/.bash_history

echo $HISTSIZE
100000

echo $HISTFILESIZE
100000

set -o | grep history
history         on

ls -ltr .bash_history
-rw-r--r-- 1 myname staff 0 Jul  1 12:31 .bash_history

I tried to delete e create again the .bash_history file without resolve.

if i change from bash to zsh with the command chsh -s /bin/zsh it works, but i need to use /bin/bash

Please someone can help me?

1 Answers

I saw this article for mac,

Do you have a ls -l /etc/bashrc_Apple_Terminal file If you do, this seems to setup a HISTFILE and totally ignores any attempt at setting your own HISTFILE

After reading the comments in the /etc/bashrc_Apple_Terminal, it seems you can set the following variable in your $HOME/.bash_profile file: SHELL_SESSION_HISTORY=0

-rw-r--r-- 1 root wheel 8909 Oct 17 2016 /etc/bashrc_Apple_Terminal and disable this behavior so that your own HISTFILE settings will take, or even honor the default bash history file name.

Once I set SHELL_SESSION_HISTORY=0 my Terminal bash history behavior started to behave as expected.

Related