Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/test_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Environment

- OS: XXX (Windows, macOS, latest Ubuntu LTS)
- Shell: XXX (Command Prompt, PowerShell, bash, fish)
- Shell: XXX (Command Prompt, PowerShell, bash, fish, xonsh)
- Python
- Distribution: XXX (CPython, miniconda)
- Version: XXX (2.7, latest 3.x)
Expand Down
1 change: 1 addition & 0 deletions news/1 Enhancements/3487.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for the Xonsh shell
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ export class Bash extends BaseActivationCommandProvider {
targetShell === TerminalShellType.zsh ||
targetShell === TerminalShellType.cshell ||
targetShell === TerminalShellType.tcshell ||
targetShell === TerminalShellType.fish;
targetShell === TerminalShellType.fish ||
targetShell === TerminalShellType.xonsh;
}
public async getActivationCommandsForInterpreter(pythonPath: string, targetShell: TerminalShellType): Promise<string[] | undefined> {
const scriptFile = await this.findScriptFile(pythonPath, this.getScriptsInOrderOfPreference(targetShell));
if (!scriptFile) {
return;
}
return [`source ${scriptFile.fileToCommandArgument()}`];

if (targetShell === TerminalShellType.xonsh) {
return [`conda ${scriptFile.fileToCommandArgument()}`];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work.
What if the environment is NOT conda?
E.g. assume you have a virtual environment or pipenv environment.

} else {
return [`source ${scriptFile.fileToCommandArgument()}`];
}
}

private getScriptsInOrderOfPreference(targetShell: TerminalShellType): string[] {
Expand Down
2 changes: 2 additions & 0 deletions src/client/common/terminal/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const IS_POWERSHELL_CORE = /(pwsh.exe$|pwsh$)/i;
const IS_FISH = /(fish$)/i;
const IS_CSHELL = /(csh$)/i;
const IS_TCSHELL = /(tcsh$)/i;
const IS_XONSH = /(xonsh$)/i;

@injectable()
export class TerminalHelper implements ITerminalHelper {
Expand All @@ -42,6 +43,7 @@ export class TerminalHelper implements ITerminalHelper {
this.detectableShells.set(TerminalShellType.tcshell, IS_TCSHELL);
this.detectableShells.set(TerminalShellType.cshell, IS_CSHELL);
this.detectableShells.set(TerminalShellType.powershellCore, IS_POWERSHELL_CORE);
this.detectableShells.set(TerminalShellType.xonsh, IS_XONSH);
}
public createTerminal(title?: string): Terminal {
const terminalManager = this.serviceContainer.get<ITerminalManager>(ITerminalManager);
Expand Down
1 change: 1 addition & 0 deletions src/client/common/terminal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum TerminalShellType {
cshell = 'cshell',
tcshell = 'tshell',
wsl = 'wsl',
xonsh = 'xonsh',
other = 'other'
}

Expand Down
1 change: 1 addition & 0 deletions src/test/common/terminals/activation.bash.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ suite('Terminal Environment Activation (bash)', () => {
case TerminalShellType.gitbash:
case TerminalShellType.tcshell:
case TerminalShellType.cshell:
case TerminalShellType.xonsh:
case TerminalShellType.fish: {
expect(supported).to.be.equal(true, `${shellType.name} shell not supported (it should be)`);
break;
Expand Down