diff --git a/src/vs/platform/terminal/node/terminalEnvironment.ts b/src/vs/platform/terminal/node/terminalEnvironment.ts index dcbff469770..78009d3c17e 100644 --- a/src/vs/platform/terminal/node/terminalEnvironment.ts +++ b/src/vs/platform/terminal/node/terminalEnvironment.ts @@ -193,6 +193,14 @@ export function getShellIntegrationInjection( source: path.join(appRoot, 'out/vs/workbench/contrib/terminal/browser/media/shellIntegration.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') + }); if (!options.showWelcome) { envMixin['VSCODE_SHELL_HIDE_WELCOME'] = '1'; } diff --git a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts index 84fb8a7e08d..df8212d7c34 100644 --- a/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts +++ b/src/vs/platform/terminal/test/node/terminalEnvironment.test.ts @@ -87,14 +87,22 @@ suite('platform - terminalEnvironment', () => { suite('zsh', () => { suite('should override args', () => { const expectedDir = /.+\/vscode-zsh/; - const expectedDest = /.+\/vscode-zsh\/.zshrc/; - const expectedSource = /.+\/out\/vs\/workbench\/contrib\/terminal\/browser\/media\/shellIntegration.zsh/; + const expectedDests = [/.+\/vscode-zsh\/.zshrc/, /.+\/vscode-zsh\/.zprofile/, /.+\/vscode-zsh\/.zshenv/]; + const expectedSources = [ + /.+\/out\/vs\/workbench\/contrib\/terminal\/browser\/media\/shellIntegration.zsh/, + /.+\/out\/vs\/workbench\/contrib\/terminal\/browser\/media\/shellIntegration-profile.zsh/, + /.+\/out\/vs\/workbench\/contrib\/terminal\/browser\/media\/shellIntegration-env.zsh/ + ]; function assertIsEnabled(result: IShellIntegrationConfigInjection) { strictEqual(Object.keys(result.envMixin!).length, 1); ok(result.envMixin!['ZDOTDIR']?.match(expectedDir)); - strictEqual(result.filesToCopy?.length, 1); - ok(result.filesToCopy[0].dest.match(expectedDest)); - ok(result.filesToCopy[0].source.match(expectedSource)); + strictEqual(result.filesToCopy?.length, 3); + ok(result.filesToCopy[0].dest.match(expectedDests[0])); + ok(result.filesToCopy[1].dest.match(expectedDests[1])); + ok(result.filesToCopy[2].dest.match(expectedDests[2])); + ok(result.filesToCopy[0].source.match(expectedSources[0])); + ok(result.filesToCopy[1].source.match(expectedSources[1])); + ok(result.filesToCopy[2].source.match(expectedSources[2])); } test('when undefined, []', () => { const result1 = getShellIntegrationInjection({ executable: 'zsh', args: [] }, enabledProcessOptions); diff --git a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-env.zsh b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-env.zsh new file mode 100644 index 00000000000..26ab335881a --- /dev/null +++ b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-env.zsh @@ -0,0 +1,8 @@ +# --------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# --------------------------------------------------------------------------------------------- + +if [[ $options[norcs] = off && -o "login" && -f ~/.zshenv ]]; then + . ~/.zshenv +fi diff --git a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-profile.zsh b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-profile.zsh new file mode 100644 index 00000000000..734bb831e11 --- /dev/null +++ b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration-profile.zsh @@ -0,0 +1,8 @@ +# --------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# --------------------------------------------------------------------------------------------- + +if [[ $options[norcs] = off && -o "login" && -f ~/.zprofile ]]; then + . ~/.zprofile +fi diff --git a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.zsh b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.zsh index cfba2786a3e..2dec005daf4 100644 --- a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.zsh +++ b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.zsh @@ -12,13 +12,8 @@ builtin unset ZDOTDIR # as disable it by unsetting the variable. VSCODE_SHELL_INTEGRATION=1 -if [ -f ~/.zshenv ]; then - . ~/.zshenv -fi -if [[ -o "login" && -f ~/.zprofile ]]; then - . ~/.zprofile -fi -if [ -f ~/.zshrc ]; then + +if [[ $options[norcs] = off && -f ~/.zshrc ]]; then . ~/.zshrc fi