Skip to content

--no-cd flag ignored when using interactive picker #1330

Closed

Description

@cperalt

I use worktrunk with tmux — each worktree has a corresponding tmux session, and I have a post-switch hook that switches my tmux client to the matching session. Because of this,
I use --no-cd so the shell in the current tmux session doesn't change directories (I only want the tmux switch, not a directory change in the source session).

Expected behavior:
wt switch --no-cd should skip the directory change regardless of whether a branch is specified directly or selected via the interactive picker.

Actual behavior:

  • wt switch --no-cd main — works correctly, no directory change, hooks run as expected
  • wt switch --no-cd (opens picker, select a branch) — the directory change still happens after selection

Use case:

~/.config/worktrunk/config.toml

[post-switch]
tmux = """
SESSION="mpos-{{ branch | sanitize }}"
if tmux has-session -t "$SESSION" 2>/dev/null; then
if [ -n "${TMUX:-}" ]; then
tmux switch-client -t "$SESSION"
else
tmux attach-session -t "$SESSION"
fi
fi
"""

alias wts="wt switch --no-cd"

When I run wts from my main tmux session, pick a branch, and then switch back to the main session, the shell's working directory has changed to the selected worktree's path.

Version: 0.28.2

Activity

  1. added a commit that references this issue on Mar 7, 2026
    a57408e
  2. worktrunk-bot commented on Mar 7, 2026

    @worktrunk-bot
    Collaborator

    Thanks for reporting this! I was able to identify the root cause: the interactive picker hardcoded change_dir: true when calling handle_switch_output(), so the --no-cd flag was never plumbed through from the CLI to the picker's switch path.

    I've opened #1331 with a fix. A maintainer will review it shortly.

  3. added a commit that references this issue on Mar 7, 2026
    db14500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions