0

I'm using zsh from vscode integrated terminal

i also use hyper terminal, warp and iterm2 for other purposes but i like to use the integreated terminal while in vscode. i actually enjoy my heavy .zshrc config on external terminals, but i often get the popup "your shell environment is taking too long to load" from vscode. Tbh, i don't mind the popup itself, but i think that a lot of the features that are useful outside vscode are not needed inside.

How can i set a different .zshrc to load only to be used by the vscode integreated terminal ?

tried conditional loading from my .zshrc but don't like it

tried setting it in the vscode-settings.json

  1. this self-answer confused me more
  2. this i think points in the right direction but i am not sure how to use task.json

my env:

  • macOS 13.1 22C65 arm64
  • Apple M1 Max
  • vscode (1.74.11ad8d514439d5077d2b0b7ee64d2ce82a9308e5a for arm64)
  • zsh 5.9 (arm-apple-darwin22.1.0)
3
  • I don't know visual studio, so just some musings instead of an answer: Does VStudio set specific environment variables (or can you configure it to do so), when running your shell? You could then catch this variable in your ~/.zshenv and, if you know that you are under VStudio, set the variable ZDOTDIR to the directory containing your zsh setup files. Commented Dec 15, 2022 at 15:54
  • 1
    Actually, if VStudio allows you to define environment variables when running your shell, you could define there the ZDOTDIR and then cause all setup files to be executed from that directory. Commented Dec 15, 2022 at 15:55
  • solved it, i don't know how to self-answer the question so i will write here:
    – aaurso
    Commented Dec 16, 2022 at 18:17

2 Answers 2

2

These are the settings to change in “settings.json”:
I created 3 profiles:

  1. zsh-minimal with the vscode minimal config -> new ZDOTDIR
  2. zsh-full with my usual heavy config -> probably not necessary since it is $HOME by default i think
  3. bash, just in case i fu everything

set to null old profiles ( zsh and zsh(2)) to delete them from profiles selection dropdown menu, as per official documentation.

“terminal.integrated.defaultProfile.osx”: “zsh-minimal”,
“terminal.integrated.profiles.osx”: {
    "zsh-minimal": {
        "title": "zsh-minimal",
        "path": "/opt/homebrew/bin//zsh",
        "icon": "terminal",
        "color": "terminal.ansiMagenta",
        "args": [
            "-l",
            "-i"
        ],
        "cwd": "${workspaceFolder}",
        "env": {
            "ZDOTDIR": "/Users/MYUSERNAME/.homesick/repos/MYUSERNAME-dotfiles/home/vscode_zsh"
        },
    },
    "zsh-full": {
        "title": "zsh-full",
        "path": "/opt/homebrew/bin//zsh",
        "icon": "terminal",
        "color": "terminal.ansiCyan",
        "args": [
            "-l",
            "-i"
        ],
        "cwd": "${workspaceFolder}",
        "env": {
            "ZDOTDIR": "/Users/MYUSERNAME/"
        },
    },
    "bash": {
        "title": "bash",
        "path": "/bin/bash",
        "icon": "terminal",
        "color": "terminal.ansiWhite",
        "args": [
            "-l",
            "-i"
        ],
        "cwd": "${workspaceFolder}",
    },
    "zsh":  null, 
    "zsh (2)": null,
}
1
  • Good idea. I would also have made a profile variant for a zsh login-shell and for a non-login-shell. Commented Dec 24, 2022 at 13:21
0

This is an easy solution: Just wrap your .zshrc with the settings that you want to run with inside that "not in vscode" and the one another the settings that you dont want to run or disable in vscode in "not in vscode"

if [ "$TERM_PROGRAM" = "vscode" ]
then
echo "in vscode"
else
echo "not in vscode"
fi

Not the answer you're looking for? Browse other questions tagged or ask your own question.