Skip to content

Add dispatch path to print a session working directory for cd #330

Description

@jongio

Problem

Jumping into a session's working directory from the shell is clumsy. dispatch info --json includes the directory, but you have to pipe it through jq to get a bare path, and dispatch open --print prints the resume command, not the folder. There is no single command that resolves a session to just its directory.

Solution

Add dispatch path that prints one session's working directory and nothing else, so it drops straight into a subshell:

cd "$(dispatch path my-alias)"

It resolves the session the same way dispatch open does: by full ID, alias, short ID prefix, --last (most recent), or --current (auto-detect from the working directory). It reuses the existing resolver so the matching rules stay identical.

Output is the absolute path on stdout with a trailing newline. If the session has no recorded directory, or the directory no longer exists on disk, it prints a clear message to stderr and exits non-zero so cd "$(...)" fails loudly instead of landing in the wrong place.

Acceptance criteria

  • dispatch path <id> prints the session's absolute working directory and exits 0
  • Resolution supports alias, short ID prefix, --last, and --current, matching dispatch open
  • A session with an empty directory exits non-zero with a message on stderr
  • A directory that no longer exists exits non-zero with a distinct message on stderr
  • Ambiguous or unknown references produce the same errors dispatch open gives
  • Unit tests cover each resolution path and both error cases
  • README and dispatch man document the command

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions