How to restore bash history function in macOS Sierra

bashhistoryterminal

I installed Sierra OS on my iMac without any troubles. But, when I open Terminal, I can't scroll through the bash history when pressing the up arrow.

Best Answer

Have a look at /etc/bashrc_Apple_Terminal. The file contains comments that explain how to disable bash_sessions:

# The save/restore mechanism is disabled if the following file exists:
#
# ~/.bash_sessions_disable

or just disable their shell history mechanism

# You may disable this behavior and share a single history by setting
# SHELL_SESSION_HISTORY to 0. There are some common user customizations
# that arrange to share new commands among running shells by
# manipulating the history at each prompt, and they typically include
# 'shopt -s histappend'; therefore, if the histappend shell option is
# enabled, per-session history is disabled by default. You may
# explicitly enable it by setting SHELL_SESSION_HISTORY to 1.