More Precise Solution: Keep Powerlevel10k in IDE Terminal
@BoboChen’s solution works great, but I found it also disables Powerlevel10k in Cursor’s built-in IDE terminal, which isn’t ideal if you want the full theme experience there.
The Issue with Broad Detection
Using TERM_PROGRAM == "vscode"
affects both:
Agent terminals (where we want minimal config)
IDE built-in terminal (where we want full Powerlevel10k)
Better Solution: Use VSCODE_SHELL_INTEGRATION
After testing environment variables, I discovered that VSCODE_SHELL_INTEGRATION
is the perfect differentiator:
Environment | VSCODE_SHELL_INTEGRATION |
---|---|
Agent Terminal | '1' |
IDE Built-in Terminal | '' (empty) |
Updated .zshrc Configuration
Replace the detection logic with this more precise version:
# Agent detection - only activate minimal mode for actual agents
if [[ -n "$VSCODE_SHELL_INTEGRATION" ]]; then
POWERLEVEL9K_INSTANT_PROMPT=off
# Disable complex prompt features for AI agents
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
# Ensure non-interactive mode
export DEBIAN_FRONTEND=noninteractive
export NONINTERACTIVE=1
fi
# Your existing Powerlevel10k instant prompt setup...
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Theme selection - disable only for agents
if [[ -n "$VSCODE_SHELL_INTEGRATION" ]]; then
ZSH_THEME="" # Disable Powerlevel10k for agents
else
ZSH_THEME="powerlevel10k/powerlevel10k" # Full theme for IDE terminal
fi
# Later in your .zshrc - minimal prompt for agents
if [[ -n "$VSCODE_SHELL_INTEGRATION" ]]; then
PROMPT='%n@%m:%~%# '
RPROMPT=''
unsetopt CORRECT
unsetopt CORRECT_ALL
setopt NO_BEEP
setopt NO_HIST_BEEP
setopt NO_LIST_BEEP
# Agent-friendly aliases
alias rm='rm -f'
alias cp='cp -f'
alias mv='mv -f'
alias npm='npm --no-fund --no-audit'
alias yarn='yarn --non-interactive'
alias pip='pip --quiet'
alias git='git -c advice.detachedHead=false'
else
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
fi
Results
Agent terminals: No hangs, minimal prompt, fast startup
IDE built-in terminal: Full Powerlevel10k theme and functionality
Clean separation: Only agents get the minimal config
This approach gives you the best of both worlds - preventing agent hangs while preserving your beautiful terminal experience in the IDE!
Hope this helps others who want to keep their full terminal setup in the IDE.