Search code examples
macosbashosx-elcapitan

How can I disable Bash sessions in OS X El Capitan


A seemingly new feature in OS X El Capitan (10.11 Beta) is Bash sessions (Terminal sessions). I now have a ~/.bash_sessions directory with history files, and my HISTFILE and HISTIGNORE envars are being overridden. How can I disable all of this functionality?


Solution

  • This behavior is defined in /etc/bashrc_Apple_Terminal. It contains documentation comments describing what it does and how to customize it.

    You can disable the per-terminal-session command history feature by setting SHELL_SESSION_HISTORY=0 in your ~/.bashrc script, as described here:

    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.

    Note that, although you can disable the entire session-state restoration mechanism by creating ~/.bash_sessions_disable, this is unnecessary just to disable the per-session command history feature, and is not recommended.