gemini-cli - 💡(How to fix) Fix Feature Request: Persistent /cd command for directory navigation within active sessions [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25020Fetched 2026-04-10 03:45:20
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2closed ×1
RAW_BUFFERClick to expand / collapse

Currently, Gemini CLI lacks a persistent way to change the working directory after a session has started. While users can run shell commands using '!cd', these changes are stateless and do not persist beyond the individual command execution. This creates friction when working on multi-repo projects or when needing to switch contexts without restarting the CLI.

Proposed Solution: Implement a built-in slash command (e.g., '/cd <path>') that updates the current working directory for the remainder of the session. This would allow:

  1. Context Switching: Easily moving between related directories/projects.
  2. Relative Pathing: Allowing tools like 'read_file' or 'run_shell_command' to resolve paths relative to the new directory.
  3. Consistency: Aligning the CLI's behavior with standard terminal expectations while maintaining the safety of the agent environment.

Alternatives Considered:

  • Using '--include-directories' at startup (requires knowing all paths beforehand).
  • Using '/directory add' (adds context but doesn't change the 'current' directory for commands).

extent analysis

TL;DR

Implementing a built-in slash command, such as '/cd <path>', is likely the most effective fix to enable persistent working directory changes within the Gemini CLI session.

Guidance

  • Consider the proposed solution's benefits, including context switching, relative pathing, and consistency with standard terminal expectations.
  • Evaluate the trade-offs of the alternatives considered, such as using '--include-directories' at startup or '/directory add', to determine if they can be adapted or combined to achieve the desired functionality.
  • Assess the potential impact of introducing a stateful directory change on the overall CLI behavior and user experience.
  • Investigate how the new slash command would handle edge cases, such as navigating to a non-existent directory or resolving relative paths.

Example

No explicit code snippet is provided in the issue, but an example of how the '/cd <path>' command could be implemented might involve updating the CLI's internal state to reflect the new working directory and ensuring that subsequent commands respect this change.

Notes

The proposed solution assumes that the Gemini CLI has the necessary infrastructure to support stateful changes to the working directory. If this is not the case, additional groundwork may be required to enable such functionality.

Recommendation

Apply the proposed workaround by implementing the '/cd <path>' slash command, as it addresses the core issue of persistent working directory changes and aligns with standard terminal expectations, thereby enhancing the user experience.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING