From 11dac22ae01b1ffa0e934294d57ebe4fa36c2871 Mon Sep 17 00:00:00 2001 From: Hunter Tunnicliff Date: Wed, 16 Oct 2024 16:24:30 -0700 Subject: [PATCH] docs: add tip for conditional shims using TERM_PROGRAM --- docs/ide-integration.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/ide-integration.md b/docs/ide-integration.md index 7eb1c4424..bb416920b 100644 --- a/docs/ide-integration.md +++ b/docs/ide-integration.md @@ -40,6 +40,33 @@ end This assumes that `mise` is on PATH. If it is not, you'll need to use the absolute path ( e.g.: `eval "$($HOME/.local/bin/mise activate zsh)"`). +:::: tip +Conditionally using shims is also possible. Some programs will set a `TERM_PROGRAM` environment +variable, which may be used to determine which activation strategy to use. + +Here is an example using VSCode: + +::: code-group +```zsh +# ~/.zprofile +if [[ "$TERM_PROGRAM" == "vscode" ]]; then + eval "$($HOME/.local/bin/mise activate zsh --shims)" +elif; then + eval "$($HOME/.local/bin/mise activate zsh)" +fi +``` + +```bash +# ~/.bash_profile or ~/.bash_login or ~/.profile +if [[ "$TERM_PROGRAM" == "vscode" ]]; then + eval "$($HOME/.local/bin/mise activate bash --shims)" +elif; then + eval "$($HOME/.local/bin/mise activate bash)" +fi +``` +::: +:::: + This won't work for all of mise's functionality. For example, arbitrary env vars in `[env]` will only be set if a shim is executed. For this we need tighter integration with the IDE and a custom plugin. If you