feat: display current directory in terminal title#1519
Conversation
Include the current working directory in the terminal window/tab title so users can identify which project each kimi session belongs to when working with multiple terminal windows or tabs. Format: 'Kimi Code — ~/path/to/project' The title updates both at startup and when entering/leaving a session's working directory, keeping it always in sync. Closes MoonshotAI#1475
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fea964c474
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| original_cwd = KaosPath.cwd() | ||
| await kaos.chdir(self._runtime.session.work_dir) | ||
| update_terminal_title_with_cwd(str(self._runtime.session.work_dir)) |
There was a problem hiding this comment.
Send cwd title updates through the original TTY stderr
In the normal kimi startup path we call redirect_stderr_to_logger() before entering _env() (src/kimi_cli/cli/__init__.py:546-548), and StderrRedirector.install() replaces fd 2 with a pipe (src/kimi_cli/utils/logging.py:38-45). Because set_terminal_title() bails out when sys.stderr.isatty() is false, the new _env() updates are a no-op for shell/print/ACP/wire runs, so the terminal tab keeps the startup title instead of the session directory this feature is meant to show.
Useful? React with 👍 / 👎.
Related Issue
Resolve #1475
Description
Since v1.15.0 (#1254), the terminal window/tab title is set to a static
"Kimi Code"string. This makes it difficult to distinguish between multiple kimi sessions in different projects when working with multiple terminal tabs or windows.Changes:
proctitle.pyto include the current working directory in the terminal titleKimi Code — ~/path/to/project(home directory abbreviated with~)update_terminal_title_with_cwd()function that can be called when the cwd changesapp.pyso the title updates when entering/leaving a session's working directoryBefore: Terminal title shows
Kimi Code(cannot tell which project)After: Terminal title shows
Kimi Code — ~/projects/myrepo(each tab identifiable)Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.