1
votes

Last night I went into my bash shell in terminal and entered a few commands. Then today I go in but theyre not saved in the history (arrow up). However the really old commands I used about 5 or more months ago are there, so the history is not empty.

Why is my history no longer activated and how do I activate it?

3

3 Answers

2
votes

macOS Catalina uses zsh as your shell, so your shell settings go to ~/.zshrc

Edit your settings:

nano ~/.zshrc

Add these lines to your ~/.zshrc file:

HISTSIZE=100000
HISTFILESIZE=999999
SAVEHIST=$HISTSIZE

The historycommand in zshalso shows only 16 most recent lines from the history file unless you give it the start line as a parameter:

history 0

This will show you the whole history.

You can make an alias for this, so that the history command without the parameter will show the complete history as well:

Add this line to your ~/.zshrc file:

alias history="history 0"
1
votes

I switched from zsh to bash in OSX Catalina but the shell history wasn't saving. I had success fixing that by creating the ~/.bash_profile file and putting this inside:

export SHELL_SESSION_HISTORY=0

Got the idea from this older thread: https://apple.stackexchange.com/questions/218731/why-bash-history-on-my-mac-wont-save

0
votes

Since macOS Catalina Apple's default shell is no longer bash, but zsh. Therefore your sources will no longer come from your .bashrc or .bash_profile.

If you want to bash to be your default shell follow this steps:

System Preferences > Users and groups > right click on your user and select advance options. > On the Login Shell drop down menu select your prefered shell.

Hope this helps!