1

Here's my issue. Last week I realized that my OSX (10.11.13) Terminal no longer saves the command I execute in the history file(s).

To be more clear:

  1. I type the command test
  2. On the same terminal window, I press arrow up: it's ok, test is there
  3. If I close the terminal, reopen it and press arrow up: test is no longer there (so it jumps to a command I executed weeks ago).

Here's what printenv returns :

NVM_RC_VERSION=
rvm_bin_path=/Users/my-user/.rvm/bin
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/my-user/.rvm/gems/ruby-2.1.2
SHELL=/bin/bash
TERM=xterm-256color
IRBRC=/Users/my-user/.rvm/rubies/ruby-2.1.2/.irbrc
TMPDIR=/var/folders/4x/y0j5261j7j3142sx_82m6fxm0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.JLKMtkE4S1/Render
TERM_PROGRAM_VERSION=361.1
MY_RUBY_HOME=/Users/my-user/.rvm/rubies/ruby-2.1.2
TERM_SESSION_ID=B48F774F-86DA-4AA1-BAB7-888DCBA65E5A
NVM_DIR=/Users/my-user/.nvm
USER=my-user
_system_type=Darwin
rvm_path=/Users/my-user/.rvm
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.550eXpVGiK/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x1
rvm_prefix=/Users/my-user
PATH=/opt/local/bin:/opt/local/sbin:/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.5.3/bin:/Users/my-user/.rvm/gems/ruby-2.1.2/bin:/Users/my-user/.rvm/gems/ruby-2.1.2@global/bin:/Users/my-user/.rvm/rubies/ruby-2.1.2/bin:/Applications/MAMP/bin/php/php5.3.6/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/my-user/.rvm/bin:/sdk/android/platform-tools:/sdk/android/tools
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
PWD=/Users/my-user
LANG=fr_FR.UTF-8
_system_arch=x86_64
XPC_FLAGS=0x0
_system_version=10.11
XPC_SERVICE_NAME=0
rvm_version=1.25.15 (stable)
SHLVL=1
HOME=/Users/my-user
LOGNAME=my-user
GEM_PATH=/Users/my-user/.rvm/gems/ruby-2.1.2:/Users/my-user/.rvm/gems/ruby-2.1.2@global
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
_system_name=OSX
_=/usr/bin/printenv

Any help?

  • Probably a duplicate of I deleted .bash_history, now history isn't saved anymore (although I re-created it). I don't flag it as such though. Please try the .bash_logout file method (with the content shell_session_update) and disabling .profile/.bash_profile temporarily. – klanomath Jan 28 '16 at 9:19
  • Could you temporarily remove your ~/.bash_profile, start a new login shell, check if you have the same problem, and report this in your OQ. – daniel Azuelos Jan 28 '16 at 9:23
  • I removed my .bash_profile, started a new terminal, it seems to work again. – enguerranws Jan 28 '16 at 9:29
2

Based on this question and answer the following should work:

  • Disable ~/.profile and ~/.bash:profile by renaming it:

    mv ~/.bash_profile ~/off.bash_profile
    mv ~/.profile ~/off.profile
    
  • Create a new file ~/.bash_logout with the content shell_session_update

    echo "shell_session_update" > ~/.bash_logout
    
  • Enter killall Terminal
  • Open Terminal and enable ~/.profile and ~/.bash_profile by renaming it:

    mv ~/off.bash_profile ~/.bash_profile
    mv ~/off.profile ~/.profile
    
  • Enter killall Terminal

  • Open Terminal and check the behavior now. Remember to always enter exit now before closing a Terminal window or quitting Terminal.
  • Well, I must admit I never enter exit before closing a terminal window... That means I should enter exit 50 times per day :/ – enguerranws Jan 28 '16 at 9:39
  • @enguerranws It's a known bug of RVM. In non-RVM environments you don't need the .bash_logout file. Hmm you may create an alias e=exit? ;-) – klanomath Jan 28 '16 at 9:41
  • 1
    You are just awesome :) Saved my day thanks a lot!! – Yohan Sep 12 '16 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .