Skip to content

Commit 26e9a8d

Browse files
authored
fix HISTFILE issues (microsoft#168636)
1 parent 1d204c9 commit 26e9a8d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,23 @@ fi
1414
# as disable it by unsetting the variable.
1515
VSCODE_SHELL_INTEGRATION=1
1616

17+
# By default, zsh will set the $HISTFILE to the $ZDOTDIR location automatically. In the case of the
18+
# shell integration being injected, this means that the terminal will use a different history file
19+
# to other terminals. To fix this issue, set $HISTFILE back to the default location before ~/.zshrc
20+
# is called as that may depend upon the value.
21+
if [[ "$VSCODE_INJECTION" == "1" ]]; then
22+
HISTFILE=$USER_ZDOTDIR/.zsh_history
23+
fi
24+
1725
# Only fix up ZDOTDIR if shell integration was injected (not manually installed) and has not been called yet
1826
if [[ "$VSCODE_INJECTION" == "1" ]]; then
1927
if [[ $options[norcs] = off && -f $USER_ZDOTDIR/.zshrc ]]; then
2028
VSCODE_ZDOTDIR=$ZDOTDIR
2129
ZDOTDIR=$USER_ZDOTDIR
30+
# A user's custom HISTFILE location might be set when their .zshrc file is sourced below
2231
. $USER_ZDOTDIR/.zshrc
2332
ZDOTDIR=$VSCODE_ZDOTDIR
2433
fi
25-
26-
if [[ -f $USER_ZDOTDIR/.zsh_history && -z $HISTFILE ]]; then
27-
HISTFILE=$USER_ZDOTDIR/.zsh_history
28-
fi
2934
fi
3035

3136
# Shell integration was disabled by the shell, exit without warning assuming either the shell has

0 commit comments

Comments
 (0)