Last active
January 25, 2022 23:31
-
-
Save wwalker/f2a4ab4cc8d615a712a3737ecbbeb69a to your computer and use it in GitHub Desktop.
Why does this sometimes not save the session history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.bash_logout | |
cat "$HISTFILE" >> "$HOME"/.bash_history && /bin/rm "$HISTFILE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SESSION_START_TIME=$(date +%F_%H.%M.%S) | |
mkdir -p "$HOME"/.bash_history_sessions | |
chmod 700 "$HOME"/.bash_history_sessions | |
HISTORY_SESSION_FILE=$HOME/.bash_history_sessions/$SESSION_START_TIME | |
HISTFILE="$HOME/.bash_history_$SESSION_START_TIME" | |
__save_session_history() { | |
[[ -n "$HISTORY_SESSION_FILE" ]] && history -a "$HISTORY_SESSION_FILE" | |
} | |
PROMPT_COMMAND='__save_session_history(); $PROMPT_COMMAND' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment