Reputation: 4986
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?
Upvotes: 1
Views: 3112
Reputation: 2149
I solve the problem for myself as follow:
Check which shell is running: echo $SHELL
It should return /bin/bash. Otherwise my solution not applied.
Backup .bash_profile with: mv .bash_profile .bash_profile.bak
Close your shell with CMD + w
.
Reopen Terminal to check if bash history works, by typing some commands, then using arrow up
to check
If terminal history seems to work again. Then the cause of the error lays down in the .bash_profile. If you want to keep your .bash_profile, you should comment out each of the command in there, to find out which commands cause the problem with the Terminal history.
In my case, the cause was commands of my working place related to cloud tooling.
I hope to help someone out! Best
Upvotes: 0
Reputation: 2571
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 history
command in zsh
also 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"
Upvotes: 5
Reputation: 21
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
Upvotes: 2
Reputation: 33
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!
Upvotes: 0