From 4677bde6eea5f9b938c10d0a32fbfb412da6f62f Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Fri, 9 May 2025 13:02:04 -0700 Subject: [PATCH 1/2] feat: Add hatch shell command --- src/hatch-env-manager.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/hatch-env-manager.ts b/src/hatch-env-manager.ts index 9f191c0..e8ee14b 100644 --- a/src/hatch-env-manager.ts +++ b/src/hatch-env-manager.ts @@ -21,6 +21,7 @@ import { type EnvironmentManager, type GetEnvironmentScope, type GetEnvironmentsScope, + type PythonCommandRunConfiguration, type PythonEnvironment, type PythonEnvironmentApi, type PythonProject, @@ -236,6 +237,15 @@ export class HatchEnvManager implements EnvironmentManager { const executable = isWindows() ? paths.join(path, 'Scripts', 'python.exe') : paths.join(path, 'bin', 'python') + + const shellActivation: Map = new Map() + const shellDeactivation: Map = new Map() + + shellActivation.set('unknown', [ + { executable: 'hatch', args: ['shell', '--name', `"${name}"`] }, + ]) + shellDeactivation.set('unknown', [{ executable: 'exit' }]) + return this.api.createPythonEnvironmentItem( { name, @@ -243,10 +253,10 @@ export class HatchEnvManager implements EnvironmentManager { displayName: name, displayPath: path, tooltip: path, - environmentPath: Uri.file(path), + environmentPath: Uri.file(executable), sysPrefix: path, - version: '1', // TODO - execInfo: { run: { executable } }, + version: '3', // TODO + execInfo: { run: { executable }, shellActivation, shellDeactivation }, }, this, ) From da034c6d42499564f3ea1bd2d25f9ababb96f48f Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Mon, 23 Mar 2026 22:42:11 +0100 Subject: [PATCH 2/2] fix args --- src/hatch-env-manager.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hatch-env-manager.ts b/src/hatch-env-manager.ts index 0a97bd6..7fa86e5 100644 --- a/src/hatch-env-manager.ts +++ b/src/hatch-env-manager.ts @@ -386,11 +386,13 @@ export class HatchEnvManager implements EnvironmentManager { ? paths.join(path, 'Scripts', 'python.exe') : paths.join(path, 'bin', 'python') - const shellActivation: Map = new Map() - const shellDeactivation: Map = new Map() + const shellActivation: Map = + new Map() + const shellDeactivation: Map = + new Map() shellActivation.set('unknown', [ - { executable: 'hatch', args: ['shell', '--name', `"${name}"`] }, + { executable: 'hatch', args: [`--env=${name}`, 'shell'] }, ]) shellDeactivation.set('unknown', [{ executable: 'exit' }]) @@ -403,7 +405,11 @@ export class HatchEnvManager implements EnvironmentManager { environmentPath: Uri.file(path), sysPrefix: path, version: '1', // TODO - execInfo: { run: { executable }, shellActivation, shellDeactivation }, + execInfo: { + run: { executable }, + shellActivation, + shellDeactivation, + }, } // make sure `getCallingExtension` leads to the correct managerId const {