Repository navigation
fix: keep zsh history in the user's HISTFILE - #494
Open
taf (tashifkhan) wants to merge 1 commit into
Open
taf (tashifkhan) wants to merge 1 commit into
taf (tashifkhan) wants to merge 1 commit into
Conversation
On macOS, /etc/zshrc sets HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history before the user's .zshrc runs. inshellisense points ZDOTDIR at a per-session temporary directory, so history was read from and saved to that directory, and new sessions started with an empty history. Point HISTFILE back at USER_ZDOTDIR when it still refers to the temporary directory.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #493
On macOS,
/etc/zshrcsetsHISTFILE=${ZDOTDIR:-$HOME}/.zsh_historybefore the user's.zshrcruns. Because inshellisense starts zsh withZDOTDIRset to a per-session temporary directory,HISTFILEends up pointing at$TMPDIR/is-zsh-<pid>/.zsh_history. History is then read from and saved to that file, so each new session starts empty.This change sets
HISTFILEback to$USER_ZDOTDIR/.zsh_historywhen it still points at the temporary directory. It runs before the user's.zshrcis sourced, so aHISTFILEset there still takes precedence. AHISTFILEset anywhere else, or left unset, is not changed.Testing on macOS 27.2 with zsh 5.9 and a
.zshrcthat does not setHISTFILE:echo $HISTFILEprinted$TMPDIR/is-zsh-<pid>/.zsh_history, and Up in a new session recalled nothing.echo $HISTFILEprints~/.zsh_history, and Up in a new session recalls entries from earlier sessions.HISTFILEset before the check is left unchanged.