Shell 模式(Ctrl+X)应使用用户默认 Shell 而非固定 /bin/sh
问题描述
在 zsh(或 fish 等)环境下启动 Kimi Code CLI 后,按 Ctrl+X 进入 Shell 模式,输入的命令实际上是由 /bin/sh 执行的,而不是用户当前的默认 Shell。
复现步骤
- 确保当前终端为 zsh:
echo $SHELL → /bin/zsh
- 启动
kimi
- 按
Ctrl+X 切换到 Shell 模式
- 输入
echo $0 或尝试使用 zsh 别名/函数
实际结果
命令由 /bin/sh 执行,zsh 的别名、函数、插件扩展语法均不可用。
期望结果
Shell 模式应识别并复用用户的默认 Shell(通过 $SHELL 环境变量),或者在 asyncio.create_subprocess_shell() 时通过 executable= 参数显式指定。
相关代码位置
kimi_cli/ui/shell/__init__.py 第 739 行左右:
# TODO: For the sake of simplicity, we now use `create_subprocess_shell`.
proc = await asyncio.create_subprocess_shell(command, env=get_clean_env(), **kwargs)
asyncio.create_subprocess_shell 在 POSIX 上默认使用 /bin/sh。建议通过 executable=os.environ.get("SHELL", "/bin/sh") 传入用户默认 Shell。
另外,kimi_cli/utils/environment.py 中的 Environment.detect() 目前只检测 bash/sh,建议扩展为优先检测 $SHELL,以支持 zsh、fish 等常用 Shell。
使用场景
- 使用 zsh 别名(如
ll、gs 等)加速操作
- 依赖 zsh 函数或特定语法的脚本/命令
- 保持与终端一致的行为,降低上下文切换成本
环境信息
- OS: macOS / Linux
- Shell: zsh
- kimi-cli version: latest
Shell mode (Ctrl+X) should use the user default Shell instead of the fixed /bin/sh
Problem description
After starting Kimi Code CLI in the zsh (or fish, etc.) environment, press Ctrl+X to enter Shell mode. The entered command is actually executed by /bin/sh instead of the user's current default Shell.
Reproduction steps
- Make sure the current terminal is zsh:
echo $SHELL → /bin/zsh
- Start
kimi
- Press
Ctrl+X to switch to Shell mode
- Type
echo $0 or try using zsh alias/function
Actual results
The command is executed by /bin/sh, and zsh's aliases, functions, and plug-in extension syntax are not available.
Expected results
Shell mode should recognize and reuse the user's default shell (via the $SHELL environment variable), or specified explicitly via the executable= parameter when asyncio.create_subprocess_shell().
Relevant code location
kimi_cli/ui/shell/__init__.py around line 739:
# TODO: For the sake of simplicity, we now use `create_subprocess_shell`.
proc = await asyncio.create_subprocess_shell(command, env=get_clean_env(), **kwargs)
asyncio.create_subprocess_shell defaults to /bin/sh on POSIX. It is recommended to pass in the user default Shell through executable=os.environ.get("SHELL", "/bin/sh").
In addition, Environment.detect() in kimi_cli/utils/environment.py currently only detects bash/sh. It is recommended to extend it to detect $SHELL first to support common shells such as zsh and fish.
Usage scenarios
- Use zsh aliases (such as
ll, gs, etc.) to speed up operations
- Scripts/commands that rely on zsh functions or specific syntax
- Maintain consistent behavior with the terminal and reduce context switching costs
Environment information
- OS: macOS/Linux
- Shell: zsh
- kimi-cli version: latest
Shell 模式(Ctrl+X)应使用用户默认 Shell 而非固定
/bin/sh问题描述
在 zsh(或 fish 等)环境下启动 Kimi Code CLI 后,按
Ctrl+X进入 Shell 模式,输入的命令实际上是由/bin/sh执行的,而不是用户当前的默认 Shell。复现步骤
echo $SHELL→/bin/zshkimiCtrl+X切换到 Shell 模式echo $0或尝试使用 zsh 别名/函数实际结果
命令由
/bin/sh执行,zsh 的别名、函数、插件扩展语法均不可用。期望结果
Shell 模式应识别并复用用户的默认 Shell(通过
$SHELL环境变量),或者在asyncio.create_subprocess_shell()时通过executable=参数显式指定。相关代码位置
kimi_cli/ui/shell/__init__.py第 739 行左右:asyncio.create_subprocess_shell在 POSIX 上默认使用/bin/sh。建议通过executable=os.environ.get("SHELL", "/bin/sh")传入用户默认 Shell。另外,
kimi_cli/utils/environment.py中的Environment.detect()目前只检测bash/sh,建议扩展为优先检测$SHELL,以支持 zsh、fish 等常用 Shell。使用场景
ll、gs等)加速操作环境信息
Shell mode (Ctrl+X) should use the user default Shell instead of the fixed
/bin/shProblem description
After starting Kimi Code CLI in the zsh (or fish, etc.) environment, press
Ctrl+Xto enter Shell mode. The entered command is actually executed by/bin/shinstead of the user's current default Shell.Reproduction steps
echo $SHELL→/bin/zshkimiCtrl+Xto switch to Shell modeecho $0or try using zsh alias/functionActual results
The command is executed by
/bin/sh, and zsh's aliases, functions, and plug-in extension syntax are not available.Expected results
Shell mode should recognize and reuse the user's default shell (via the
$SHELLenvironment variable), or specified explicitly via theexecutable=parameter whenasyncio.create_subprocess_shell().Relevant code location
kimi_cli/ui/shell/__init__.pyaround line 739:asyncio.create_subprocess_shelldefaults to/bin/shon POSIX. It is recommended to pass in the user default Shell throughexecutable=os.environ.get("SHELL", "/bin/sh").In addition,
Environment.detect()inkimi_cli/utils/environment.pycurrently only detectsbash/sh. It is recommended to extend it to detect$SHELLfirst to support common shells such as zsh and fish.Usage scenarios
ll,gs, etc.) to speed up operationsEnvironment information