1. Olle Lundberg
  2. dotfiles

Commits

Olle Lundberg  committed 111e0c3

Copy old history to new file, if new file does not exist.

  • Participants
  • Parent commits 01d3c95
  • Branches default

Comments (0)

Files changed (1)

File .bashrc.d/10_history.sh

View file
 shopt -s cmdhist
 
 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HFILE="${HOME}/.bash_history_$(hostname)"
+OHFILE="${HOME}/.bash_history"
 
-export HISTFILE="${HOME}/.bash_history_$(hostname)"
+if [ ! -r "${HFILE}" ]; then
+	cat "${OHFILE}" > "${HFILE}" 2>/dev/null;
+	if [ $? -ne 0 ]; then
+		HFILE=$OHFILE
+	fi
+fi
+
+export HISTFILE="${HFILE}"
 export HISTSIZE=100000
 export HISTFILESIZE=100000