Bash History Not Preserved Between Terminal Sessions on Mac












26















My bash history mysteriously stopped working, and I have no idea how to fix it. This is what my .bashrc looks like:



HISTSIZE=500
HISTFILESIZE=500
HISTFILE=$HOME/.bash_history


However, when i run echo $HISTFILE it prints out /Users/myusername/.bash_sessions/EE8689E5-7DAD-4018-817E-0AF1DE36082A.historynew.



I am the owner of the .bash_history file, so I'm not too sure how I would go about fixing this issue.



Thanks!










share|improve this question

























  • Hi Nelson, welcome to Super User. Quick check- ere those spaces inserted by you?

    – bertieb
    Aug 4 '15 at 9:20













  • yes they were, i'll remove them and report back.

    – Nelson Liu
    Aug 4 '15 at 9:20











  • @bertieb, I've removed the spaces and now $HISTFILESIZE is properly echo'd. However, history remains unsaved and $HISTFILE prints out that odd temp history file (which I'm assuming stores history for just that session).

    – Nelson Liu
    Aug 4 '15 at 9:22











  • Are you trying to change $HISTFILE, out of interest? I don't have a .bashrc on OSX and echo $HISTFILE reports the place I would expect- does commenting out the lines in question have any effect?

    – bertieb
    Aug 4 '15 at 9:42













  • Where are you sourcing .bashrc? On OS X, you normally have a login shell.

    – fd0
    Aug 4 '15 at 10:08
















26















My bash history mysteriously stopped working, and I have no idea how to fix it. This is what my .bashrc looks like:



HISTSIZE=500
HISTFILESIZE=500
HISTFILE=$HOME/.bash_history


However, when i run echo $HISTFILE it prints out /Users/myusername/.bash_sessions/EE8689E5-7DAD-4018-817E-0AF1DE36082A.historynew.



I am the owner of the .bash_history file, so I'm not too sure how I would go about fixing this issue.



Thanks!










share|improve this question

























  • Hi Nelson, welcome to Super User. Quick check- ere those spaces inserted by you?

    – bertieb
    Aug 4 '15 at 9:20













  • yes they were, i'll remove them and report back.

    – Nelson Liu
    Aug 4 '15 at 9:20











  • @bertieb, I've removed the spaces and now $HISTFILESIZE is properly echo'd. However, history remains unsaved and $HISTFILE prints out that odd temp history file (which I'm assuming stores history for just that session).

    – Nelson Liu
    Aug 4 '15 at 9:22











  • Are you trying to change $HISTFILE, out of interest? I don't have a .bashrc on OSX and echo $HISTFILE reports the place I would expect- does commenting out the lines in question have any effect?

    – bertieb
    Aug 4 '15 at 9:42













  • Where are you sourcing .bashrc? On OS X, you normally have a login shell.

    – fd0
    Aug 4 '15 at 10:08














26












26








26


12






My bash history mysteriously stopped working, and I have no idea how to fix it. This is what my .bashrc looks like:



HISTSIZE=500
HISTFILESIZE=500
HISTFILE=$HOME/.bash_history


However, when i run echo $HISTFILE it prints out /Users/myusername/.bash_sessions/EE8689E5-7DAD-4018-817E-0AF1DE36082A.historynew.



I am the owner of the .bash_history file, so I'm not too sure how I would go about fixing this issue.



Thanks!










share|improve this question
















My bash history mysteriously stopped working, and I have no idea how to fix it. This is what my .bashrc looks like:



HISTSIZE=500
HISTFILESIZE=500
HISTFILE=$HOME/.bash_history


However, when i run echo $HISTFILE it prints out /Users/myusername/.bash_sessions/EE8689E5-7DAD-4018-817E-0AF1DE36082A.historynew.



I am the owner of the .bash_history file, so I'm not too sure how I would go about fixing this issue.



Thanks!







macos bash unix terminal history






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 4 '15 at 9:23







Nelson Liu

















asked Aug 4 '15 at 9:18









Nelson LiuNelson Liu

131124




131124













  • Hi Nelson, welcome to Super User. Quick check- ere those spaces inserted by you?

    – bertieb
    Aug 4 '15 at 9:20













  • yes they were, i'll remove them and report back.

    – Nelson Liu
    Aug 4 '15 at 9:20











  • @bertieb, I've removed the spaces and now $HISTFILESIZE is properly echo'd. However, history remains unsaved and $HISTFILE prints out that odd temp history file (which I'm assuming stores history for just that session).

    – Nelson Liu
    Aug 4 '15 at 9:22











  • Are you trying to change $HISTFILE, out of interest? I don't have a .bashrc on OSX and echo $HISTFILE reports the place I would expect- does commenting out the lines in question have any effect?

    – bertieb
    Aug 4 '15 at 9:42













  • Where are you sourcing .bashrc? On OS X, you normally have a login shell.

    – fd0
    Aug 4 '15 at 10:08



















  • Hi Nelson, welcome to Super User. Quick check- ere those spaces inserted by you?

    – bertieb
    Aug 4 '15 at 9:20













  • yes they were, i'll remove them and report back.

    – Nelson Liu
    Aug 4 '15 at 9:20











  • @bertieb, I've removed the spaces and now $HISTFILESIZE is properly echo'd. However, history remains unsaved and $HISTFILE prints out that odd temp history file (which I'm assuming stores history for just that session).

    – Nelson Liu
    Aug 4 '15 at 9:22











  • Are you trying to change $HISTFILE, out of interest? I don't have a .bashrc on OSX and echo $HISTFILE reports the place I would expect- does commenting out the lines in question have any effect?

    – bertieb
    Aug 4 '15 at 9:42













  • Where are you sourcing .bashrc? On OS X, you normally have a login shell.

    – fd0
    Aug 4 '15 at 10:08

















Hi Nelson, welcome to Super User. Quick check- ere those spaces inserted by you?

– bertieb
Aug 4 '15 at 9:20







Hi Nelson, welcome to Super User. Quick check- ere those spaces inserted by you?

– bertieb
Aug 4 '15 at 9:20















yes they were, i'll remove them and report back.

– Nelson Liu
Aug 4 '15 at 9:20





yes they were, i'll remove them and report back.

– Nelson Liu
Aug 4 '15 at 9:20













@bertieb, I've removed the spaces and now $HISTFILESIZE is properly echo'd. However, history remains unsaved and $HISTFILE prints out that odd temp history file (which I'm assuming stores history for just that session).

– Nelson Liu
Aug 4 '15 at 9:22





@bertieb, I've removed the spaces and now $HISTFILESIZE is properly echo'd. However, history remains unsaved and $HISTFILE prints out that odd temp history file (which I'm assuming stores history for just that session).

– Nelson Liu
Aug 4 '15 at 9:22













Are you trying to change $HISTFILE, out of interest? I don't have a .bashrc on OSX and echo $HISTFILE reports the place I would expect- does commenting out the lines in question have any effect?

– bertieb
Aug 4 '15 at 9:42







Are you trying to change $HISTFILE, out of interest? I don't have a .bashrc on OSX and echo $HISTFILE reports the place I would expect- does commenting out the lines in question have any effect?

– bertieb
Aug 4 '15 at 9:42















Where are you sourcing .bashrc? On OS X, you normally have a login shell.

– fd0
Aug 4 '15 at 10:08





Where are you sourcing .bashrc? On OS X, you normally have a login shell.

– fd0
Aug 4 '15 at 10:08










6 Answers
6






active

oldest

votes


















20














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.



A new folder (~/.bash_sessions/) is used to store HISTFILE's and .session files that are unique to sessions.



During shell startup the session file is executed. Old files are periodically deleted.



The default behavior arranges to save and restore the bash command history independently for each restored terminal session. It also merges commands into the global history for new sessions.



You may disable this behavior and share a single history by setting



export SHELL_SESSION_HISTORY=0


If HISTTIMEFORMAT is defined, per-session history is disabled by default (read more in /private/etc/bashrc_Apple_Terminal)



The save/restore mechanism is disabled if the following file exists:



~/.bash_sessions_disable


Apple already changed some behavior since El Capitan release, so it is better to go read more about this here less /private/etc/bashrc_Apple_Terminal






share|improve this answer





















  • 3





    But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

    – Chris Page
    Dec 30 '15 at 12:41













  • @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

    – diimdeep
    Dec 30 '15 at 15:07













  • @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

    – zerohedge
    May 14 '17 at 0:23













  • @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

    – diimdeep
    May 14 '17 at 6:57











  • @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

    – zerohedge
    May 14 '17 at 13:52



















6














I noticed something similar after the El Capitan upgrade. Simply adding the file .bash_sessions_disable file in your home directory disables the new bash sessions and the .bash_history is back in use.



This Reddit thread has more info and further links.






share|improve this answer


























  • But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

    – Chris Page
    Dec 30 '15 at 12:44













  • Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

    – rabs
    Feb 25 '16 at 0:53











  • @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

    – Teejay
    Dec 27 '17 at 16:18



















4














You can solve RVM problem by updating to latest RVM version or executing this:



  echo 'shell_session_update' > $HOME/.bash_logout


See https://github.com/rvm/rvm/issues/3540 for more info.






share|improve this answer



















  • 1





    Nice fix, without having to modify rvm.

    – mlo55
    Aug 8 '17 at 6:31



















3














This answer from the Reddit thread saved me:




It's probably RVM preventing the exit "hook" for bash_sessions to run. If you comment out the following line in your .bash_profile, it should work.




[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"





share|improve this answer
























  • This indeed helped!

    – Karsten
    Mar 19 '17 at 21:06



















0














If it's a Mac, I suppose it's default login shell is bash and it runs .profile instead of .bashrc. So, you were editing the wrong file.






share|improve this answer
























  • I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

    – Nelson Liu
    Aug 7 '15 at 18:18











  • @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

    – theoden
    Aug 7 '15 at 18:52













  • how would I echo $HISTFILE in different parts of profile?

    – Nelson Liu
    Aug 8 '15 at 19:12











  • @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

    – theoden
    Aug 8 '15 at 19:16













  • Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

    – Nelson Liu
    Aug 9 '15 at 4:52





















0














I was seeing this problem on High Sierra. Somehow, my own .bash_history had become owned by root and not even having read permissions for other users (when contents of home directory viewed with ls -al)



There was nothing of any consequence in this .bash_history file, so I did a sudo rm .bash_history followed by a touch .bash_history to make a new one.



All seems well now






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f950403%2fbash-history-not-preserved-between-terminal-sessions-on-mac%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    6 Answers
    6






    active

    oldest

    votes








    6 Answers
    6






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    20














    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.



    A new folder (~/.bash_sessions/) is used to store HISTFILE's and .session files that are unique to sessions.



    During shell startup the session file is executed. Old files are periodically deleted.



    The default behavior arranges to save and restore the bash command history independently for each restored terminal session. It also merges commands into the global history for new sessions.



    You may disable this behavior and share a single history by setting



    export SHELL_SESSION_HISTORY=0


    If HISTTIMEFORMAT is defined, per-session history is disabled by default (read more in /private/etc/bashrc_Apple_Terminal)



    The save/restore mechanism is disabled if the following file exists:



    ~/.bash_sessions_disable


    Apple already changed some behavior since El Capitan release, so it is better to go read more about this here less /private/etc/bashrc_Apple_Terminal






    share|improve this answer





















    • 3





      But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:41













    • @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

      – diimdeep
      Dec 30 '15 at 15:07













    • @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

      – zerohedge
      May 14 '17 at 0:23













    • @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

      – diimdeep
      May 14 '17 at 6:57











    • @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

      – zerohedge
      May 14 '17 at 13:52
















    20














    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.



    A new folder (~/.bash_sessions/) is used to store HISTFILE's and .session files that are unique to sessions.



    During shell startup the session file is executed. Old files are periodically deleted.



    The default behavior arranges to save and restore the bash command history independently for each restored terminal session. It also merges commands into the global history for new sessions.



    You may disable this behavior and share a single history by setting



    export SHELL_SESSION_HISTORY=0


    If HISTTIMEFORMAT is defined, per-session history is disabled by default (read more in /private/etc/bashrc_Apple_Terminal)



    The save/restore mechanism is disabled if the following file exists:



    ~/.bash_sessions_disable


    Apple already changed some behavior since El Capitan release, so it is better to go read more about this here less /private/etc/bashrc_Apple_Terminal






    share|improve this answer





















    • 3





      But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:41













    • @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

      – diimdeep
      Dec 30 '15 at 15:07













    • @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

      – zerohedge
      May 14 '17 at 0:23













    • @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

      – diimdeep
      May 14 '17 at 6:57











    • @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

      – zerohedge
      May 14 '17 at 13:52














    20












    20








    20







    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.



    A new folder (~/.bash_sessions/) is used to store HISTFILE's and .session files that are unique to sessions.



    During shell startup the session file is executed. Old files are periodically deleted.



    The default behavior arranges to save and restore the bash command history independently for each restored terminal session. It also merges commands into the global history for new sessions.



    You may disable this behavior and share a single history by setting



    export SHELL_SESSION_HISTORY=0


    If HISTTIMEFORMAT is defined, per-session history is disabled by default (read more in /private/etc/bashrc_Apple_Terminal)



    The save/restore mechanism is disabled if the following file exists:



    ~/.bash_sessions_disable


    Apple already changed some behavior since El Capitan release, so it is better to go read more about this here less /private/etc/bashrc_Apple_Terminal






    share|improve this answer















    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.



    A new folder (~/.bash_sessions/) is used to store HISTFILE's and .session files that are unique to sessions.



    During shell startup the session file is executed. Old files are periodically deleted.



    The default behavior arranges to save and restore the bash command history independently for each restored terminal session. It also merges commands into the global history for new sessions.



    You may disable this behavior and share a single history by setting



    export SHELL_SESSION_HISTORY=0


    If HISTTIMEFORMAT is defined, per-session history is disabled by default (read more in /private/etc/bashrc_Apple_Terminal)



    The save/restore mechanism is disabled if the following file exists:



    ~/.bash_sessions_disable


    Apple already changed some behavior since El Capitan release, so it is better to go read more about this here less /private/etc/bashrc_Apple_Terminal







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 30 '15 at 15:06

























    answered Oct 11 '15 at 12:37









    diimdeepdiimdeep

    6222715




    6222715








    • 3





      But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:41













    • @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

      – diimdeep
      Dec 30 '15 at 15:07













    • @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

      – zerohedge
      May 14 '17 at 0:23













    • @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

      – diimdeep
      May 14 '17 at 6:57











    • @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

      – zerohedge
      May 14 '17 at 13:52














    • 3





      But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:41













    • @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

      – diimdeep
      Dec 30 '15 at 15:07













    • @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

      – zerohedge
      May 14 '17 at 0:23













    • @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

      – diimdeep
      May 14 '17 at 6:57











    • @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

      – zerohedge
      May 14 '17 at 13:52








    3




    3





    But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

    – Chris Page
    Dec 30 '15 at 12:41







    But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

    – Chris Page
    Dec 30 '15 at 12:41















    @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

    – diimdeep
    Dec 30 '15 at 15:07







    @ChrisPage Actually Apple changed some bits of script. Updated answer, thanks.

    – diimdeep
    Dec 30 '15 at 15:07















    @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

    – zerohedge
    May 14 '17 at 0:23







    @diimdeep Where would I append this line? export SHELL_SESSION_HISTORY=0

    – zerohedge
    May 14 '17 at 0:23















    @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

    – diimdeep
    May 14 '17 at 6:57





    @zerohedge .bashrc and .bash_profile unix.stackexchange.com/a/310150/15362

    – diimdeep
    May 14 '17 at 6:57













    @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

    – zerohedge
    May 14 '17 at 13:52





    @diimdeep Thank you. This seems to be working right now. Does it have any ramifications?

    – zerohedge
    May 14 '17 at 13:52













    6














    I noticed something similar after the El Capitan upgrade. Simply adding the file .bash_sessions_disable file in your home directory disables the new bash sessions and the .bash_history is back in use.



    This Reddit thread has more info and further links.






    share|improve this answer


























    • But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:44













    • Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

      – rabs
      Feb 25 '16 at 0:53











    • @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

      – Teejay
      Dec 27 '17 at 16:18
















    6














    I noticed something similar after the El Capitan upgrade. Simply adding the file .bash_sessions_disable file in your home directory disables the new bash sessions and the .bash_history is back in use.



    This Reddit thread has more info and further links.






    share|improve this answer


























    • But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:44













    • Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

      – rabs
      Feb 25 '16 at 0:53











    • @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

      – Teejay
      Dec 27 '17 at 16:18














    6












    6








    6







    I noticed something similar after the El Capitan upgrade. Simply adding the file .bash_sessions_disable file in your home directory disables the new bash sessions and the .bash_history is back in use.



    This Reddit thread has more info and further links.






    share|improve this answer















    I noticed something similar after the El Capitan upgrade. Simply adding the file .bash_sessions_disable file in your home directory disables the new bash sessions and the .bash_history is back in use.



    This Reddit thread has more info and further links.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 3 '16 at 17:59









    JakeGould

    31.3k1096138




    31.3k1096138










    answered Nov 23 '15 at 3:51









    rabsrabs

    16112




    16112













    • But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:44













    • Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

      – rabs
      Feb 25 '16 at 0:53











    • @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

      – Teejay
      Dec 27 '17 at 16:18



















    • But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

      – Chris Page
      Dec 30 '15 at 12:44













    • Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

      – rabs
      Feb 25 '16 at 0:53











    • @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

      – Teejay
      Dec 27 '17 at 16:18

















    But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

    – Chris Page
    Dec 30 '15 at 12:44







    But don’t just start by disabling the save/restore mechanism. If you’re having issues with the shell command history, try to resolve that issue. The ~/.bash_sessions_disable file is meant as a last resort in case there’s an issue that can’t be resolved specifically. It disables more than just the per-session command histories, and you can disable just the per-session command history. See the comments in /etc/bashrc_Apple_Terminal for details.

    – Chris Page
    Dec 30 '15 at 12:44















    Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

    – rabs
    Feb 25 '16 at 0:53





    Thanks Chris - what else does it disable my history has been working as expected (same as previous osx version and same as linux) for the last couple of months. Don't know why they changed it?

    – rabs
    Feb 25 '16 at 0:53













    @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

    – Teejay
    Dec 27 '17 at 16:18





    @rabs I'd suggest adding SHELL_SESSION_HISTORY=0 at the top of ~/.bash_profile.

    – Teejay
    Dec 27 '17 at 16:18











    4














    You can solve RVM problem by updating to latest RVM version or executing this:



      echo 'shell_session_update' > $HOME/.bash_logout


    See https://github.com/rvm/rvm/issues/3540 for more info.






    share|improve this answer



















    • 1





      Nice fix, without having to modify rvm.

      – mlo55
      Aug 8 '17 at 6:31
















    4














    You can solve RVM problem by updating to latest RVM version or executing this:



      echo 'shell_session_update' > $HOME/.bash_logout


    See https://github.com/rvm/rvm/issues/3540 for more info.






    share|improve this answer



















    • 1





      Nice fix, without having to modify rvm.

      – mlo55
      Aug 8 '17 at 6:31














    4












    4








    4







    You can solve RVM problem by updating to latest RVM version or executing this:



      echo 'shell_session_update' > $HOME/.bash_logout


    See https://github.com/rvm/rvm/issues/3540 for more info.






    share|improve this answer













    You can solve RVM problem by updating to latest RVM version or executing this:



      echo 'shell_session_update' > $HOME/.bash_logout


    See https://github.com/rvm/rvm/issues/3540 for more info.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 17 '17 at 19:19









    Alex RojoAlex Rojo

    411




    411








    • 1





      Nice fix, without having to modify rvm.

      – mlo55
      Aug 8 '17 at 6:31














    • 1





      Nice fix, without having to modify rvm.

      – mlo55
      Aug 8 '17 at 6:31








    1




    1





    Nice fix, without having to modify rvm.

    – mlo55
    Aug 8 '17 at 6:31





    Nice fix, without having to modify rvm.

    – mlo55
    Aug 8 '17 at 6:31











    3














    This answer from the Reddit thread saved me:




    It's probably RVM preventing the exit "hook" for bash_sessions to run. If you comment out the following line in your .bash_profile, it should work.




    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"





    share|improve this answer
























    • This indeed helped!

      – Karsten
      Mar 19 '17 at 21:06
















    3














    This answer from the Reddit thread saved me:




    It's probably RVM preventing the exit "hook" for bash_sessions to run. If you comment out the following line in your .bash_profile, it should work.




    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"





    share|improve this answer
























    • This indeed helped!

      – Karsten
      Mar 19 '17 at 21:06














    3












    3








    3







    This answer from the Reddit thread saved me:




    It's probably RVM preventing the exit "hook" for bash_sessions to run. If you comment out the following line in your .bash_profile, it should work.




    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"





    share|improve this answer













    This answer from the Reddit thread saved me:




    It's probably RVM preventing the exit "hook" for bash_sessions to run. If you comment out the following line in your .bash_profile, it should work.




    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 1 '16 at 9:35









    noionoio

    18618




    18618













    • This indeed helped!

      – Karsten
      Mar 19 '17 at 21:06



















    • This indeed helped!

      – Karsten
      Mar 19 '17 at 21:06

















    This indeed helped!

    – Karsten
    Mar 19 '17 at 21:06





    This indeed helped!

    – Karsten
    Mar 19 '17 at 21:06











    0














    If it's a Mac, I suppose it's default login shell is bash and it runs .profile instead of .bashrc. So, you were editing the wrong file.






    share|improve this answer
























    • I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

      – Nelson Liu
      Aug 7 '15 at 18:18











    • @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

      – theoden
      Aug 7 '15 at 18:52













    • how would I echo $HISTFILE in different parts of profile?

      – Nelson Liu
      Aug 8 '15 at 19:12











    • @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

      – theoden
      Aug 8 '15 at 19:16













    • Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

      – Nelson Liu
      Aug 9 '15 at 4:52


















    0














    If it's a Mac, I suppose it's default login shell is bash and it runs .profile instead of .bashrc. So, you were editing the wrong file.






    share|improve this answer
























    • I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

      – Nelson Liu
      Aug 7 '15 at 18:18











    • @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

      – theoden
      Aug 7 '15 at 18:52













    • how would I echo $HISTFILE in different parts of profile?

      – Nelson Liu
      Aug 8 '15 at 19:12











    • @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

      – theoden
      Aug 8 '15 at 19:16













    • Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

      – Nelson Liu
      Aug 9 '15 at 4:52
















    0












    0








    0







    If it's a Mac, I suppose it's default login shell is bash and it runs .profile instead of .bashrc. So, you were editing the wrong file.






    share|improve this answer













    If it's a Mac, I suppose it's default login shell is bash and it runs .profile instead of .bashrc. So, you were editing the wrong file.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Aug 6 '15 at 13:29









    theodentheoden

    519519




    519519













    • I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

      – Nelson Liu
      Aug 7 '15 at 18:18











    • @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

      – theoden
      Aug 7 '15 at 18:52













    • how would I echo $HISTFILE in different parts of profile?

      – Nelson Liu
      Aug 8 '15 at 19:12











    • @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

      – theoden
      Aug 8 '15 at 19:16













    • Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

      – Nelson Liu
      Aug 9 '15 at 4:52





















    • I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

      – Nelson Liu
      Aug 7 '15 at 18:18











    • @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

      – theoden
      Aug 7 '15 at 18:52













    • how would I echo $HISTFILE in different parts of profile?

      – Nelson Liu
      Aug 8 '15 at 19:12











    • @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

      – theoden
      Aug 8 '15 at 19:16













    • Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

      – Nelson Liu
      Aug 9 '15 at 4:52



















    I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

    – Nelson Liu
    Aug 7 '15 at 18:18





    I've edited .profile so it is the same as my .bashrc, and history still doesn't come up.

    – Nelson Liu
    Aug 7 '15 at 18:18













    @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

    – theoden
    Aug 7 '15 at 18:52







    @NelsonLiu What happens when you echo $HISTFILE in different parts of profile? Maybe you source another script that changes the variable? I checked both Terminal and iTerm, bash 3 and 4 both have their default $HOME/.bash_history.

    – theoden
    Aug 7 '15 at 18:52















    how would I echo $HISTFILE in different parts of profile?

    – Nelson Liu
    Aug 8 '15 at 19:12





    how would I echo $HISTFILE in different parts of profile?

    – Nelson Liu
    Aug 8 '15 at 19:12













    @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

    – theoden
    Aug 8 '15 at 19:16







    @NelsonLiu, isn't it obvious? your aim is to track when does $HISTFILE change. Thus, simply make two echo $HISTFILE surround your code. What you have to do is to find the piece of code where $HISTFILE changes by moving both echo $HISTFILE lines closer and closer to each other line-by-line until something reveals. That's all.

    – theoden
    Aug 8 '15 at 19:16















    Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

    – Nelson Liu
    Aug 9 '15 at 4:52







    Hi @theoden, sorry for my misunderstanding. Interestingly enough, when I add a echo $HISTFILE to the start and end of my .profile, no output is produced. when I add an echo $HISTFILE to the start and end of my .bash_profile, however, the proper $HISTFILE is outputted. (/Users/myuser/.bash_history). What else should I try? Sorry, I'm pretty new to shell.

    – Nelson Liu
    Aug 9 '15 at 4:52













    0














    I was seeing this problem on High Sierra. Somehow, my own .bash_history had become owned by root and not even having read permissions for other users (when contents of home directory viewed with ls -al)



    There was nothing of any consequence in this .bash_history file, so I did a sudo rm .bash_history followed by a touch .bash_history to make a new one.



    All seems well now






    share|improve this answer




























      0














      I was seeing this problem on High Sierra. Somehow, my own .bash_history had become owned by root and not even having read permissions for other users (when contents of home directory viewed with ls -al)



      There was nothing of any consequence in this .bash_history file, so I did a sudo rm .bash_history followed by a touch .bash_history to make a new one.



      All seems well now






      share|improve this answer


























        0












        0








        0







        I was seeing this problem on High Sierra. Somehow, my own .bash_history had become owned by root and not even having read permissions for other users (when contents of home directory viewed with ls -al)



        There was nothing of any consequence in this .bash_history file, so I did a sudo rm .bash_history followed by a touch .bash_history to make a new one.



        All seems well now






        share|improve this answer













        I was seeing this problem on High Sierra. Somehow, my own .bash_history had become owned by root and not even having read permissions for other users (when contents of home directory viewed with ls -al)



        There was nothing of any consequence in this .bash_history file, so I did a sudo rm .bash_history followed by a touch .bash_history to make a new one.



        All seems well now







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 4 at 16:09









        Julian JordanJulian Jordan

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f950403%2fbash-history-not-preserved-between-terminal-sessions-on-mac%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            RAC Tourist Trophy