Skip to content

Commit 7c0e956

Browse files
Enhance .zshrc to detect AI coding agent sessions and adjust prompt theme accordingly, improving user experience in different environments.
1 parent 4b76c7b commit 7c0e956

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

common/zsh/.zshrc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ esac
1515
# Should be set at the very top of interactive session settings
1616
stty -ixon
1717

18+
# Detect AI coding agent sessions that conflict with heavy prompt themes
19+
_is_agent_session() {
20+
[[ -n "$CURSOR_AGENT" || -n "$GEMINI_CLI" ]]
21+
}
22+
1823
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
1924
# Initialization code that may require console input (password prompts, [y/n]
2025
# confirmations, etc.) must go above this block; everything else may go below.
21-
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-$(print -P %n).zsh" ]]; then
26+
if ! _is_agent_session && [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-$(print -P %n).zsh" ]]; then
2227
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-$(print -P %n).zsh"
2328
fi
2429

@@ -52,7 +57,11 @@ ZSH_DISABLE_COMPFIX=true
5257
# load a random theme each time Oh My Zsh is loaded, in which case,
5358
# to know which specific one was loaded, run: echo $RANDOM_THEME
5459
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
55-
ZSH_THEME="powerlevel10k/powerlevel10k"
60+
if _is_agent_session; then
61+
ZSH_THEME="robbyrussell"
62+
else
63+
ZSH_THEME="powerlevel10k/powerlevel10k"
64+
fi
5665

5766
ENABLE_CORRECTION="true"
5867
COMPLETION_WAITING_DOTS="true"
@@ -160,4 +169,4 @@ fi
160169
zstyle ':completion:*' special-dirs false
161170

162171
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
163-
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
172+
! _is_agent_session && [[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh

0 commit comments

Comments
 (0)