How to automatically use Warp Terminal's Subshells with "Warpify"

Software engineer and entrepreneur based in San Francisco.
Warp Terminal is a modern terminal emulator that brings powerful features to command-line workflows. One of its standout features is subshells - isolated terminal environments for different contexts. In this post, we'll explore how to automate the use of subshells using a custom configuration I call "Warpify".
What are Warp Subshells?
Warp subshells provide isolated environments where you can run commands without affecting your main terminal session. They're perfect for things like ssh'ing to a server, or looking inside a docker container (e.g., docker exec), each with their own environment variables and working directories.
How to auto Warpify Subshells
Add this to your .bashrc
or .zshrc
file to automatically use Warp subshells when you open a new terminal session.
For modern macOS if you have JetBrains IDE(s) installed (to exclude them):
# Warpify subshells
if [[ "$TERM_PROGRAM" == "WarpTerminal" ]]; then
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "zsh" }}\x9c'
fi```
To have the basic config appended to the file automatically, you can just run the following command in your terminal (for macOS):
```bash
echo 'printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "zsh" }}\x9c'' >> ~/.zshrc
For Linux:
# Warpify subshells
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "bash" }}\x9c'
See this article for further documentation on this: Warpify Subshells.