Back to Blog

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

December 31, 2024
William Callahan
William Callahan

Software engineer and entrepreneur based in San Francisco.

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

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):

bash
# 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:

bash
# Warpify subshells
printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "bash" }}\x9c'

See this article for further documentation on this: Warpify Subshells.