Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 258
Whymarrh Avatar asked Sep 05 '15 22:09

Whymarrh


People also ask

How do I disable bash on a Mac?

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.

How do I stop scripts from running on my Mac?

Otherwise, you can press Esc (or Command-period on a Mac) to abort the script. If you have FMA you can open the Script Debugger. First time you open it the script should stop on the current step.

How do I stop a terminal from restoring session?

since there's currently no way to disable the message but keeping the functionality, executing clear command on the terminal startup is my current workaround. for powershell, just add clear command to the profile. Save this answer.

What is bash terminal in Mac?

Mac OS X comes with the Bourne Again SHell (bash) as the default user shell and also includes the TENEX C shell (tcsh), the Korn shell (ksh), and the Z shell (zsh). bash, ksh, and zsh are compatible with sh, the original Bourne shell.

What is sudo access on Mac?

sudo stands for superuser do. You're asked for the password of the current user. You're asked to enter the password for adminUsername, after which a new shell is opened for that user. If a command requires it, you can use su to switch to the root user.


2 Answers

If you startup a new Bash session manually (i.e. bash -xl), you can see what is run on login.

You'll see the following line in the output:

.... +++ '[' '!' -e /Users/username/.bash_sessions_disable ']' 

You can create a .bash_sessions_disable file in your home directory to disable this functionality.

like image 115
Whymarrh Avatar answered Sep 22 '22 15:09

Whymarrh


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.

like image 44
Chris Page Avatar answered Sep 22 '22 15:09

Chris Page