Agent not detecting that a command has completed

Same for me. Pasting that into .zshrc doesn’t work for me

I appear to have solved this with the following alterations to my .zshrc

if [[ -n $CURSOR_TRACE_ID ]]; then
  ZSH_THEME="robbyrussell"  # Use a simpler theme in Cursor
else
  ZSH_THEME="powerlevel10k/powerlevel10k"
fi

# Other things

if [[ ! -n $CURSOR_TRACE_ID ]]; then
  [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
fi

The terminal now recognises commands have finished

4 Likes
if [[ "$PAGER" == "head -n 10000 | cat" ]]; then
  ZSH_THEME="robbyrussell"
else
  ZSH_THEME="powerlevel10k/powerlevel10k"
fi

This worked for me, as this PAGER env variable is only set to this value when Cursor runs on Agent Mode. It keeps the powerlevel10k theme everywhere else.

1 Like

I found that commenting out oh-my-zsh in .zshrc fixed the issue, so I added this:

if [[ ! -n $CURSOR_TRACE_ID ]]; then
  source $ZSH/oh-my-zsh.sh
fi

Not a great solution, but an OK work-around until I figure out something else.

Have you had good luck with this with Cursor 1.0. I am not seeing this as working.

Thank you so much, I solved this problem with this on Cursor 1.0.

1 Like

Hi Steve, yes, I’m using 1.0.

This solved my issue with power10k + zsh.

Here is a guide:

  1. run
curl -L https://iterm2.com/shell_integration/zsh -o ~/.iterm2_shell_integration.zsh
  1. on your .zshrc add (nano ~/.zshrc)
PROMPT_EOL_MARK=""

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

precmd() {
    print -Pn "\e]133;D;%?\a"
}

preexec() {
    print -Pn "\e]133;C;\a"
}
  1. (not sure it’s necessary) In iTerm2 enable shell integration by enabling Load shell integration automatically in Settings > Profiles > General in the Command section
  2. reload configuration
source ~/.zshrc
  1. restart cursor

I’m experiencing the same issue:

Hitting Skip causes:

image

I dont use iterm 2, never been much of a fan.

I understand this has something to do with VSCODE_SHELL_INTEGRATION

I’ve got a small workaround for it but I’d like the shell integrations if there is a more reliable solution

# # 🚫 Block Cursor from injecting shell integration early
if [[ "$TERM_PROGRAM" == "vscode" || "$TERM_PROGRAM" == "Cursor" ]]; then
  export VSCODE_SHELL_INTEGRATION=0
  return
fi

I am on Mac OS : 15.5 (Sequoia)
Terminal : Tmux / Alacritty
Shell : ZSH / Oh-My-ZSH / Power10k
Cursor: 1.0

Cursor Information:
Version: 1.1.3

VSCode Version: 1.96.2

Commit: 979ba33804ac150108481c14e0b5cb970bda3260

Date: 2025-06-15T06:35:49.230Z (1 day ago)

Electron: 34.5.1

Chromium: 132.0.6834.210

Node.js: 20.19.0

V8: 13.2.152.41-electron.0

OS: Darwin arm64 24.5.0

It seems like a ZSH issue but I figured I would post here too just in case.

1 Like

Here’s my solution

if [[ "$PAGER" != "head -n 10000 | cat" ]]; then
  source ~/powerlevel10k/powerlevel10k.zsh-theme
fi

Thanks a lot! Your solution saved me! :smiling_face_with_three_hearts:

i filed an issue today on the ohmyzshell-repository: VSCode + Cursor: zsh: command not found: q · Issue #13178 · ohmyzsh/ohmyzsh · GitHub

With these .zshrc changes, is there a way to make the Cursor user-interactive terminal (Ctrl-`) still using ZSH as my normal terminal, but make the agent’s terminal work as these snippets otherwise do?

Yes! You can keep using Zsh normally while disabling your .zshrc (and thus Oh My Zsh) only for Cursor agent terminals.

First open the .zshrc file.

nano ~/.zshrc

Then just add this line at the very top of your .zshrc:

if [[ "$TERM_PROGRAM" == "vscode" || "$TERM_PROGRAM" == "cursor" ]]; then
  return
fi

That’s All!

This ensures that when Cursor’s agent runs a terminal command, your .zshrc is skipped — preventing it from hanging. Your interactive terminal (Ctrl+`) inside Cursor will still use Zsh as expected.

Works perfectly on macOS + Oh My Zsh setups.

That wasn’t quite correct because $TERM_PROGRAM returns vscode, not cursor. But it returns that for both the interactive terminal and the agent terminal.

However, thanks to your snippet and some of the other code in here, and running export in both terminals, I found there are two simple ways to fix this.

At the top of your ~/.zshrc, add either:

[[ "$COMPOSER_NO_INTERACTION" == "1" ]] && return

Or:

[[ "$PAGER" == "head -n 10000 | cat" ]] && return

I tested both and either one works properly to make the agent terminal not use Oh My ZSH (and its theme), but keep them for the interactive terminal.

Thanks!

Thanks for the feedback!

You’re right—Cursor is a VS Code fork, so $TERM_PROGRAM may return vscode. Here’s an updated .zshrc snippet to handle both cases:

if [[ "$TERM_PROGRAM" == "vscode" || "$TERM_PROGRAM" == "cursor" ]]; then
  return
fi

This ensures the .zshrc is skipped for Cursor’s agent terminal while keeping Oh My Zsh active for the interactive terminal.

I think you’re replying to the comments I’ve since deleted and replaced with the correct code, since both terminals in Cursor use the same $TERM_PROGRAM variable.

You’re right — both agent and interactive terminals in Cursor share the same $TERM_PROGRAM, so this workaround disables .zshrc globally within Cursor.

For my use case, that’s acceptable — I prefer full zsh features in iTerm/Terminal and a clean shell for Cursor to avoid agent bugs. But for anyone wanting Oh My Zsh only in the interactive terminal, they’d need a more specific detection method (maybe tty check or env flag injection).

If you want Cursor Agent to run in a clean shell but still keep your full Zsh setup (like Oh My Zsh) in the interactive terminal (Ctrl+`), place this at the top of your .zshrc:

if [[ "$TERM_PROGRAM" == "vscode" && ! -t 1 ]]; then
  return
fi

What it does:

  • $TERM_PROGRAM == “vscode” → ensures the logic only runs inside Cursor
  • ! -t 1 → excludes interactive terminals (so your Ctrl+` terminal still loads all your configs)

Result:

  • Agent commands don’t hang anymore
  • You don’t lose your interactive terminal features
  • Clean separation between automated and manual terminal environments

Tested on macOS + Oh My Zsh + Cursor v1.1.3 – works like a charm.

Hope this helps anyone trying to keep both worlds happy!

Still occurs in bash.
Not usable to run in the background; Would recommend Roo Code.

$ echo $SHELL
/bin/bash

Have the following at the top of ~/.bashrc

if [[ "$TERM_PROGRAM" == "vscode" && ! -t 1 ]]; then
  return
fi

Version: 1.1.5 (system setup)
VSCode Version: 1.96.2
Commit: ef5eeb47a684b4c217dfaf0463aa7ea952f8ab90
Date: 2025-06-21T05:31:17.701Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.22631

MacOS bash is also encountering the problem. On latest Cursor and MacOS, and Bash 5 (not preinstalled bash 4). And yes, other platforms don’t have the same problem as Cursor.