Allowing CLI binary selection in tdPyenvManager

Right now, `tdutils/TDPyenvManagerHelper.py` uses the following code block for “Open CLI” function:

if platform.system() == 'Windows':
	activateScript = envPath / 'Scripts' / 'activate.bat'
	self.runningProcess = subprocess.Popen(['cmd.exe', '/K', str(activateScript)], creationflags=subprocess.CREATE_NEW_CONSOLE, text=True)

elif platform.system() == 'Darwin':
	activateScript = (envPath / 'bin' / 'activate').resolve()
	envPathParent = envPath.parent
	if not activateScript.exists():
		raise FileNotFoundError(f"Activation script not found at {activateScript}")

	cd_cmd = shlex.quote(str(envPathParent))
	source_cmd = shlex.quote(str(activateScript))
	osascriptCmd = f"""
	tell application "Terminal"
		activate
		do script "cd {cd_cmd} && source {source_cmd}"
	end tell
	"""
	self.runningProcess = subprocess.Popen(["osascript", "-e", osascriptCmd], text=True)

This code blocks hardcodes the app/binary name for CLI and doesn’t provide any interface to customize this selection.

I’m a macOS / iTerm user and all my tooling is set up under iTerm. Forcing Terminal with the code above results in

image

a broken experience. macOS doesn’t provide a “Open the default terminal app”, but having an option to switch from “Terminal” to any other app of my choice would make the “Open CLI” function actually useful for anyone that doesn’t use the default apps.

1 Like

This is a bit too much of a change and complicated for the current version of the TDPyEnvManager.

The activation script is already tricky on MacOS.

"""
	tell application "Terminal"
		activate
		do script "cd {cd_cmd} && source {source_cmd}"
	end tell
	"""

It looks like this would be different for iTerm.

I’ll look at opening up this in the future, but not anytime soon.

Best,
Michel

While it’s different, it’s not actually that different. Adding support for for iTerm and multiple other terminal interfaces took a day of work on my end. If there is a way to contribute it back without losing my credit, I can share the diff.