Skip to content

Commit 8d6f68f

Browse files
Apply changes to PATH after terminal creation (#952)
* set applyAtShellIntegration when changing terminal environment * apply Swift terminal PATH environment variable after shell startup
1 parent a9aa6bc commit 8d6f68f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/terminal.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ export class SwiftEnvironmentVariablesManager implements vscode.Disposable {
5656
}
5757

5858
if (configuration.path) {
59-
environment.prepend("PATH", configuration.path + pathSeparator);
59+
environment.prepend("PATH", configuration.path + pathSeparator, {
60+
applyAtShellIntegration: true,
61+
});
6062
}
6163
for (const variable in configuration.swiftEnvironmentVariables) {
62-
environment.replace(variable, configuration.swiftEnvironmentVariables[variable]);
64+
environment.replace(variable, configuration.swiftEnvironmentVariables[variable], {
65+
applyAtShellIntegration: true,
66+
});
6367
}
6468
}
6569
}
@@ -73,13 +77,18 @@ export class SwiftTerminalProfileProvider implements vscode.TerminalProfileProvi
7377
const env: vscode.TerminalOptions["env"] = {
7478
...configuration.swiftEnvironmentVariables,
7579
};
76-
const pathEnv = process.env["PATH"] ?? "";
77-
if (configuration.path) {
78-
env["PATH"] = configuration.path + pathSeparator + pathEnv;
80+
if (!configuration.enableTerminalEnvironment) {
81+
const disposable = vscode.window.onDidOpenTerminal(terminal => {
82+
if (configuration.path) {
83+
terminal.sendText(`export PATH=${configuration.path + pathSeparator}$PATH`);
84+
}
85+
disposable.dispose();
86+
});
7987
}
8088
return new vscode.TerminalProfile({
8189
name: "Swift Terminal",
8290
iconPath: new vscode.ThemeIcon("swift-icon"),
91+
shellArgs: [],
8392
env,
8493
});
8594
}

0 commit comments

Comments
 (0)