Skip to content

Instantly share code, notes, and snippets.

@karrtikr
Created March 26, 2024 19:44
Show Gist options
  • Save karrtikr/e3d2452eafa6bac3456e34f5e73f4967 to your computer and use it in GitHub Desktop.
Save karrtikr/e3d2452eafa6bac3456e34f5e73f4967 to your computer and use it in GitHub Desktop.
Terminal activation notes
When terminal opens up:
- Process creation
- Intiialization scripts (.zshrc, .bashrc, Powershell profile)
- conda init (activating base by default)
- Shell integration script
- Fails silently
- Powershell execution is disabled for windows
- Automatic shell integration may not be working
- Disables this script (based on shell config)
Variables that are prepended:
- PS1
- PATH
- (.zshrc, .bashrc, Powershell profile)
Environment activation:
- We have a selected environment that needs to be activated
- Get the environment variables that are needed to be set in temrinal, to activate this environment:
- Launch a process
- Activate env
- Print environment variables (everything may contain process specific stuff (PROCESS: true)) (diff only contains the variables which are required to activate, HOME env variable)
- Con: It does not run any shell initialization script (.zshrc, .bashrc, Powershell profile)
- Suppose if user set a certain variable there, let's say to disable the terminal prompt (.venv)
- Launch a terminal - Activate env
- Print environment variables
- Get output from shell integration API
- Not as reliable (Daniel said)
- We can know when the command finishes
- Launch a terminal (hidden terminal)
- Activate env
- Print environment variables to a file (not to stdout in terminal) (everything)
- It does not contain any terminal prompt stuff
- Get output from shell integration API
- Not as reliable (Daniel said)
- We can know when the command finishes
Task terminals: https://github.com/microsoft/vscode-python/issues/23028#issuecomment-2015613218
How will you know whether shell integration is active?
- Once you detect shell integration is working (let's say for powershell), persist that info
- Memento API
Mechansim to get output using hidden terminals:
- Just use one hidden terminal (because shell integration takes time to activate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment