Skip to content

Instantly share code, notes, and snippets.

@dzamlo
Last active September 25, 2020 12:53
Show Gist options
  • Save dzamlo/783a701c52941fa409c1a7cfa3011f1b to your computer and use it in GitHub Desktop.
Save dzamlo/783a701c52941fa409c1a7cfa3011f1b to your computer and use it in GitHub Desktop.
history_dir="${HOME}/.history/$(date +%Y/%m)"
mkdir -p "$history_dir"
HISTFILE="$history_dir/$(date --iso-8601=seconds)_${HOSTNAME}_$$"
export HISTSIZE="NOTHING"
export HISTFILESIZE="NOTHING"
export HISTTIMEFORMAT='%F %T '
HISTCONTROL=ignoreboth
shopt -s histappend
shopt -s histverify
shopt -s cmdhist
export PROMPT_COMMAND="history -a${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
all_hist_tmp=$(mktemp)
find "${HOME}/.history" -type f -printf "%T+\t%p\n" | sort | cut -f 2 | xargs cat > "$all_hist_tmp"
history -n "$all_hist_tmp"
rm "$all_hist_tmp"
alias nohistory="HISTFILE=/dev/null"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment