I deleted .bash_history, now history isn't saved anymore (although I re-created it) I have freshly installed a new copy of El Capitan. I accidently deleted .bash_history, so I just did a touch .bash_history again, hoping this would solve the problem of my bash history not being remembered when closing and re-opening the terminal.

But it didn't. And I have no idea why.

Macbuech:~ josh$ ~/.bash_history
-bash: /Users/josh/.bash_history: Permission denied
Macbuech:~ josh$ ls ~/.bash_history
/Users/josh/.bash_history
Macbuech:~ josh$ echo $HISTSIZE
500
Macbuech:~ josh$ echo $HISTFILESIZE
500
Macbuech:~ josh$ echo $HISTFILE
/Users/josh/.bash_sessions/9817540A-F021-4E1A-93A1-B322BC4738AB.historynew
Macbuech:~ josh$ echo $HISTTIMEFORMAT


I fiddled around a bit with .bash_profile to get some colors working, according to this article:

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'


I removed all the stuff again to make sure the problem's not lying there. So here's my .bash_profile:

[[ -s "$HOME/.profile" ]] &amp;&amp; source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] &amp;&amp; source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*


This site states that there may be a problem with RVM, and I tried adding a .bash_logout with shell_session_update in it, but no success.

Any help is highly appreciated.

Here's my complete env:

Macbuech:~ josh$ env
rvm_bin_path=/Users/josh/.rvm/bin
TERM_PROGRAM=Apple_Terminal
GEM_HOME=/Users/josh/.rvm/gems/ruby-2.2.4
SHELL=/bin/bash
TERM=xterm-256color
IRBRC=/Users/josh/.rvm/rubies/ruby-2.2.4/.irbrc
TMPDIR=/var/folders/sq/92dr708946s01kttg916m6xm0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.9AJd6SsR1y/Render
TERM_PROGRAM_VERSION=361.1
MY_RUBY_HOME=/Users/josh/.rvm/rubies/ruby-2.2.4
TERM_SESSION_ID=9817540A-F021-4E1A-93A1-B322BC4738AB
rvm_stored_umask=0022
USER=josh
_system_type=Darwin
rvm_path=/Users/josh/.rvm
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.gZZeyimp2O/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
rvm_prefix=/Users/josh
PATH=/Users/josh/.rvm/gems/ruby-2.2.4/bin:/Users/josh/.rvm/gems/ruby-2.2.4@global/bin:/Users/josh/.rvm/rubies/ruby-2.2.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/josh/.rvm/bin
rvm_loaded_flag=1
PWD=/Users/josh
_system_arch=x86_64
XPC_FLAGS=0x0
_system_version=10.11
XPC_SERVICE_NAME=0
rvm_version=1.26.11 (master)
SHLVL=1
HOME=/Users/josh
LOGNAME=josh
GEM_PATH=/Users/josh/.rvm/gems/ruby-2.2.4:/Users/josh/.rvm/gems/ruby-2.2.4@global
LC_CTYPE=UTF-8
RUBY_VERSION=ruby-2.2.4
rvm_user_install_flag=1
_system_name=OSX
_=/usr/bin/env
I encountered the same problem after willingly deleting the .bash_history file.

The simple solution is to not only touch the file but also add some text - one or several line feeds are not sufficient:

echo "exit" &gt;&gt; ~/.bash_history


Then completely quit Terminal and reopen it. If you've saved all your work in all terminal sessions, you can also just  

killall Terminal




Update:

I tried to replicate your environment in a 10.11 VM and it's indeed a problem with RVM: commenting out all rvm related lines in .profile and .bash_profile re-enables updates of the .bash_history file.

The .bash_logout file method (with the content shell_session_update) seems to work reliably here though. Just remember to always enter exit before closing a Terminal window or quitting Terminal. Without entering exit the history won't be updated.