Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/vs/platform/terminal/node/terminalEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ export async function getShellIntegrationInjection(
envMixin['ZDOTDIR'] = zdotdir;
const userZdotdir = env?.ZDOTDIR ?? os.homedir() ?? `~`;
envMixin['USER_ZDOTDIR'] = userZdotdir;
// Record any custom HISTFILE so the shell integration script can restore it
// instead of overwriting it with the default location (see #169264).
if (env?.HISTFILE) {
envMixin['VSCODE_ZSH_HISTFILE_ORIG'] = env.HISTFILE;
}
Comment on lines +258 to +262
const filesToCopy: IShellIntegrationConfigInjection['filesToCopy'] = [];
filesToCopy.push({
source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/common/scripts/shellIntegration-rc.zsh'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ VSCODE_SHELL_INTEGRATION=1
# By default, zsh will set the $HISTFILE to the $ZDOTDIR location automatically. In the case of the
# shell integration being injected, this means that the terminal will use a different history file
# to other terminals. To fix this issue, set $HISTFILE back to the default location before ~/.zshrc
# is called as that may depend upon the value.
# is called as that may depend upon the value. If the user (or VS Code's terminal env settings) had
# already set a custom $HISTFILE, restore that value instead so it is not clobbered (see #169264).
if [[ "$VSCODE_INJECTION" == "1" ]]; then
HISTFILE=$USER_ZDOTDIR/.zsh_history
if [[ -n "$VSCODE_ZSH_HISTFILE_ORIG" ]]; then
HISTFILE="$VSCODE_ZSH_HISTFILE_ORIG"
builtin unset VSCODE_ZSH_HISTFILE_ORIG
else
HISTFILE=$USER_ZDOTDIR/.zsh_history
fi
fi

# Only fix up ZDOTDIR if shell integration was injected (not manually installed) and has not been called yet
Expand Down
Loading