Use a redefinição a seguir para cd
e coloque essas linhas em .bashrc
:
HISTFILE=$HOME/.bash_history.'echo $PWD|sed -e 's/\//_/g''
cd () {
history -a
command cd "$@"
HISTFILE=$HOME/.bash_history.'echo $PWD|sed -e 's/\//_/g''
history -c
history -r
}