help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it necessary to use Mac's /etc/bashrc_Apple_Terminal


From: Dennis Williamson
Subject: Re: Is it necessary to use Mac's /etc/bashrc_Apple_Terminal
Date: Mon, 1 Feb 2021 08:53:04 -0600

On Mon, Feb 1, 2021, 8:25 AM Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> Mac has /etc/bashrc_Apple_Terminal loaded by the following files. It
> basically tries to save the history. But I feel sluggish when I try to
> terminate a terminal especially when my machine is busy. Even when I
> disable it with SHELL_SESSION_HISTORY=0, I still can feel the
> sluggishness.
>
> Is it appropriate to comment out the line `[ -r
> "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"` and
> only rely on the bash native way to handle history? Will this cause
> any problem? Thanks.
>
> https://gist.github.com/floam/f535842a16226e77d014d67bade2b2f3
>
> $ cat /etc/profile
> # System-wide .profile for sh(1)
>
> if [ -x /usr/libexec/path_helper ]; then
>     eval `/usr/libexec/path_helper -s`
> fi
>
> if [ "${BASH-no}" != "no" ]; then
>     [ -r /etc/bashrc ] && . /etc/bashrc
> fi
> $ cat /etc/bashrc
> # System-wide .bashrc file for interactive bash(1) shells.
> if [ -z "$PS1" ]; then
>    return
> fi
>
> PS1='\h:\W \u\$ '
> # Make bash check its window size after a process completes
> shopt -s checkwinsize
>
> [ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM"
>
> --
> Regards,
> Peng
>

If you read the script you will see what it does and can then decide
whether you need it or not. There's no harm in disabling them. You just
don't get the added functionality. Try it both ways and see what you prefer.

On my system it says

# Tell the terminal about the current working directory at each prompt.

In other words, display the directory in the terminal title.

and

# Resume Support: Save/Restore Shell State
#
# Terminal assigns each terminal session a unique identifier and
# communicates it via the TERM_SESSION_ID environment variable so that
# programs running in a terminal can save/restore application-specific
# state when quitting and restarting Terminal with Resume enabled.

with both of those features being added to PROMPT_COMMAND making them run
each time the prompt is issued.

In the script, the documented way to disable the save/restore is to create
~/.bash_sessions_disable. It has nothing to do with Bash history, by the
way. To test it, do something in the terminal then exit Terminal.app and
start it again. Try that with save/restore enabled then again with it
disabled and compare. You may need to start a new Bash session after
changes in order to get the change recognized.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]