Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh HISTFILE Hardcoded after #168396 fix #169264

Open
Redoubts opened this issue Dec 15, 2022 · 4 comments
Open

zsh HISTFILE Hardcoded after #168396 fix #169264

Redoubts opened this issue Dec 15, 2022 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh
Milestone

Comments

@Redoubts
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.74.1 (Universal)
  • OS Version: Darwin x64 22.2.0 (ssh extension into debian 10.12)

The fix for #168396 permanently overwrites my $HISTFILE setting, so I can't redirect it to another file. If I set

    "terminal.integrated.env.linux": {
        "HISTFILE": "${HOME}/something_else",
    }

in VS Code user settings or export HISTFILE="${HOME}/something_else" in my .zshenv, I see

% env | grep HIST
HISTFILE=/home/redoubts/.zsh_history

Steps to Reproduce:

  1. try to set $HISTFILE anywhere normally
  2. observe with env | grep HIST
@Tyriar
Copy link
Member

Tyriar commented Dec 16, 2022

As a temporary workaround you could set it in your .zshrc, checking TERM_PROGRAM == "vscode" if you want it only in VS Code.

I guess to fix this one we need to record any custom HISTFILE when we're constructing the envMixin:

// Move .zshrc into $ZDOTDIR as the way to activate the script
const zdotdir = path.join(os.tmpdir(), `${os.userInfo().username}-${productService.applicationName}-zsh`);
envMixin['ZDOTDIR'] = zdotdir;
const userZdotdir = env?.ZDOTDIR ?? os.homedir() ?? `~`;
envMixin['USER_ZDOTDIR'] = userZdotdir;
const filesToCopy: IShellIntegrationConfigInjection['filesToCopy'] = [];
filesToCopy.push({
source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh'),
dest: path.join(zdotdir, '.zshrc')
});
filesToCopy.push({
source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/browser/media/shellIntegration-profile.zsh'),
dest: path.join(zdotdir, '.zprofile')
});
filesToCopy.push({
source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/browser/media/shellIntegration-env.zsh'),
dest: path.join(zdotdir, '.zshenv')
});
filesToCopy.push({
source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/browser/media/shellIntegration-login.zsh'),
dest: path.join(zdotdir, '.zlogin')
});
return { newArgs, envMixin, filesToCopy };

Then if we had a custom one, assign it here:

if [[ "$VSCODE_INJECTION" == "1" ]]; then
HISTFILE=$USER_ZDOTDIR/.zsh_history
fi

@meganrogge will save this one for you for some good testing, no rush as there's an easy workaround.

@Tyriar Tyriar added this to the January 2023 milestone Dec 16, 2022
@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh labels Dec 16, 2022
@Tyriar Tyriar removed their assignment Dec 16, 2022
@meganrogge meganrogge modified the milestones: January 2023, Backlog Jan 9, 2023
@bika-c
Copy link

bika-c commented Jan 30, 2023

Will this be fixed in January update?

@kwmlodozeniec
Copy link

I have this variable set in my .zenv file and it still gets overridden somehow, to overcome that I had to disable the shell integration setting
"terminal.integrated.shellIntegration.enabled": false

@t-fritsch
Copy link

thank you @Tyriar for the suggested workaround. It didn't work for me because I need different history file for every workspace :

"terminal.integrated.env.osx": {
    "HISTFILE": "${workspaceFolder}/.zsh_history"
}

Anyway your suggestion helped me finding a temporary workaround (still hoping this bug gets fixed some day 😅) that I write here in case anyone is looking for something similar :

  1. in .vscode/settings.json, create a custom env var :
    "terminal.integrated.env.osx": {
        "VSCODE_HISTFILE": "${workspaceFolder}/.zsh_history",
    },
  2. in ~/.zshrc, check if it exists and overwrite HISTFILE :
    # fix vscode custom histfile
    # cf. https://github.com/microsoft/vscode/issues/169264
    if [[ -v VSCODE_HISTFILE ]]; then
        export HISTFILE=$VSCODE_HISTFILE
    fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-zsh An issue in the terminal specific to zsh
Projects
None yet
Development

No branches or pull requests

8 participants