Skip to content

Add setting to change the cwd of the Powershell Integrated Console #2796

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

Merged
merged 3 commits into from
Jul 8, 2020
Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@
"default": "BlockComment",
"description": "Controls the comment-based help completion behavior triggered by typing '##'. Set the generated help style with 'BlockComment' or 'LineComment'. Disable the feature with 'Disabled'."
},
"powershell.cwd": {
"type": "string",
"default": null,
"description": "An explicit start path where the Powershell Integrated Console will be launched. Both the PowerShell process and the shell's location will be set to this directory. Predefined variables can be used (i.e. ${fileDirname} to use the current opened file's directory)."
},
"powershell.scriptAnalysis.enable": {
"type": "boolean",
"default": true,
Expand Down
1 change: 1 addition & 0 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class PowerShellProcess {
shellPath: this.exePath,
shellArgs: powerShellArgs,
hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup,
cwd: this.sessionSettings.cwd
});

const pwshName = path.basename(this.exePath);
Expand Down
3 changes: 3 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface ISettings {
sideBar?: ISideBarSettings;
pester?: IPesterSettings;
buttons?: IButtonSettings;
cwd?: string;
}

export interface IStartAsLoginShellSettings {
Expand Down Expand Up @@ -257,6 +258,8 @@ export function load(): ISettings {
// is the reason terminals on macOS typically run login shells by default which set up
// the environment. See http://unix.stackexchange.com/a/119675/115410"
configuration.get<IStartAsLoginShellSettings>("startAsLoginShell", defaultStartAsLoginShellSettings),
cwd:
configuration.get<string>("cwd", null),
};
}

Expand Down