Seperate shell history for each terminal window
I have recently upgrade PyCharm and I have lost a feature that I really liked. In a previous version each terminal window would be keeping its shell history in a separate file. This was managed by setting the HISTFILE environment variable to a a different value in each terminal window. These files were in the directory ~/.bash_session.
What managed that variable and how do I enable that feature again.
Thank you in advance for any assistance.
请先登录再写评论。
It was a version from 2019. I do not have the actual version anymore.
I have this shell function in my my environment but I am not sure where it came from:
configureCommandHistory ()
{
local commandHistoryFile="$__INTELLIJ_COMMAND_HISTFILE__";
unset __INTELLIJ_COMMAND_HISTFILE__;
if [ -n "$commandHistoryFile" ] && [ -z "`trap -p EXIT`" ]; then
trap "$(builtin printf 'history -w %q; HISTFILE=%q' "$commandHistoryFile" "$HISTFILE")" EXIT;
if [ -s "$commandHistoryFile" ]; then
HISTFILE="$commandHistoryFile";
fi;
fi
}
I only have that in the PyCharm terminal. It is not in my other terminal emulators.
Maxgusdad
Based on snippet I have create solution purely in bash. It could (if you want) work for non Jetbrains terminals.
In my case it was enough to distinguish basing on current working directory - so terminal will restore its history depending on directory in which it was opened.
Script:
In `~/.bashrc` put `source <path-to-script>` or just put whole script into `.bashrc`