WebStorm's terminal on macOS is not working because of Warp's adjustments to .zshrc

113 Views Asked by At

I am using Warp (a terminal emulator for mac) for couple of months now in combination with VSCode without any issues. Warp has this feature that "wraps" shells that it runs to make it more comfortable with some GUI features, but to make it work with subshells (i.e when you open a new zsh inside another one) you have to add these lines to .zshrc:

# Warp: this is used to warpify subshells.
# Learn more: https://docs.warp.dev/features/subshells.
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "zsh" }}\x9c'

VSCode opens it's integrated terminal with zsh without any issue. But WebStorm just does not work, it just stucks at empty terminal window and stays like that forever: enter image description here

But if I remove the above Warp lines from .zshrc WebStorm's terminal starts working, but now Warp is not able to wrap the subshells.

Is this a known issue? I've tried googling but couldn't find anything relevant. I assume that the output from that printf ... somehow breaks the WebStorm, although VSCode works just fine. Is there a way to make WebStorm to sort of "ignore" what printf is writing to output?

1

There are 1 best solutions below

0
Edgar P-Yan On

I found a somewhat hacky solution: it turns out that WebStorm stores an environment variable TERMINAL_EMULATOR=JetBrains-JediTerm for it's integrated shells. So just add an if condition before the printf to check if it's running inside the WebStorms terminal or not:

# Warp: this is used to warpify subshells.
# Learn more: https://docs.warp.dev/features/subshells.
# Note: don't run it inside the WebStorms terminal, as it will break. 
if [[ ! $TERMINAL_EMULATOR = "JetBrains-JediTerm" ]]
then
    printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "zsh" }}\x9c'
fi

It works, but would be better if there is some configuration for WebStorm to just work with these kind of outputs.