Skip to content

Commit d48ac4b

Browse files
committed
feat: shorten work directory path in welcome message
Signed-off-by: Richard Chien <[email protected]>
1 parent 15adb07 commit d48ac4b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/kimi_cli/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from kimi_cli.soul.kimisoul import KimiSoul
2222
from kimi_cli.soul.runtime import Runtime
2323
from kimi_cli.utils.logging import StreamToLogger, logger
24+
from kimi_cli.utils.path import shorten_home
2425

2526

2627
def enable_logging(debug: bool = False) -> None:
@@ -150,7 +151,9 @@ async def run_shell_mode(self, command: str | None = None) -> bool:
150151
from kimi_cli.ui.shell import ShellApp, WelcomeInfoItem
151152

152153
welcome_info = [
153-
WelcomeInfoItem(name="Directory", value=str(self._runtime.session.work_dir)),
154+
WelcomeInfoItem(
155+
name="Directory", value=str(shorten_home(self._runtime.session.work_dir))
156+
),
154157
WelcomeInfoItem(name="Session", value=self._runtime.session.id),
155158
]
156159
if base_url := self._env_overrides.get("KIMI_BASE_URL"):

src/kimi_cli/utils/path.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,15 @@ def list_directory(work_dir: Path) -> str:
7272
errors="replace",
7373
)
7474
return ls.stdout.strip()
75+
76+
77+
def shorten_home(path: Path) -> Path:
78+
"""
79+
Convert absolute path to use `~` for home directory.
80+
"""
81+
try:
82+
home = Path.home()
83+
p = path.relative_to(home)
84+
return Path("~") / p
85+
except ValueError:
86+
return path

0 commit comments

Comments
 (0)