How to automatically use Warp Terminal's Subshells with "Warpify"
Software engineer and entrepreneur based in San Francisco.
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".
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.
Add the snippet to the appropriate RC file in the target environment. For SSH/containers, add it on the host you're connecting to. For local nested shells, add it to your local RC.
To Warpify SSH or container sessions, add the snippet in the target environment — the machine you're connecting to (for example: a Docker container, a remote SSH server, or a VM). Place it in that user's shell startup file (~/.bashrc
or ~/.bash_profile
for bash, ~/.zshrc
for zsh).
“Local nested shells” are interactive shells you start inside your current Warp session on the same machine (not SSH, not a container). If you want these inner shells to be auto‑warpified without a prompt, add the snippet to your local RC file.
bash
, bash -l
zsh
, zsh -l
sudo -s
, sudo -i
su - otheruser
, su -l otheruser
poetry shell
, pipenv shell
nix-shell
, nix develop
asdf shell <tool> <version>
(depending on setup)tmux new -s work
, screen
What do NOT count as local nested shells (configure the host you enter instead):
docker exec -it <container> /bin/bash
→ put the snippet in the container user’s RC file.ssh user@host
(even ssh localhost
) → put the snippet on the target/remote machine.This protection boundary ensures it only runs inside Warp and only for interactive shells:
# zsh (~/.zshrc)
if [[ $- == *i* && $TERM_PROGRAM == "WarpTerminal" ]]; then
printf '\eP$f{"hook":"SourcedRcFileForWarp","value":{"shell":"zsh"}}\x9c'
fi
# bash (~/.bashrc or ~/.bash_profile)
if [[ $- == *i* && $TERM_PROGRAM == "WarpTerminal" ]]; then
printf '\eP$f{"hook":"SourcedRcFileForWarp","value":{"shell":"bash"}}\x9c'
fi
Quick add (local only — guarded) examples:
# zsh (local ~/.zshrc)
cat <<'EOF' >> ~/.zshrc
# Auto-Warpify (Warp) — only in Warp and interactive zsh
if [[ $- == *i* && $TERM_PROGRAM == "WarpTerminal" ]]; then
printf '\eP$f{"hook":"SourcedRcFileForWarp","value":{"shell":"zsh"}}\x9c'
fi
EOF
# bash (local ~/.bashrc)
cat <<'EOF' >> ~/.bashrc
# Auto-Warpify (Warp) — only in Warp and interactive bash
if [[ $- == *i* && $TERM_PROGRAM == "WarpTerminal" ]]; then
printf '\eP$f{"hook":"SourcedRcFileForWarp","value":{"shell":"bash"}}\x9c'
fi
EOF
For Linux (on the host you're connecting to):
# Warpify subshells on the host you're connecting to (remote server/container)
# Add this to the remote user's ~/.bashrc (or ~/.bash_profile)
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "bash" }}\x9c'
See this article for further documentation on this: Warpify Subshells.