farion1231 / farion1231/cc-switch
Support configurable terminal startup command for Open Terminal
- Dominant language
- Rust
- Stars
- 133k
- Forks
- 9.2k
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 51
Description
### Self Checks / 自检
- [x] I have read the [FAQ](https://github.com/farion1231/cc-switch#faq) section in README.
我已阅读 README 中的[常见问题](https://github.com/farion1231/cc-switch#常见问题)。
- [x] I have searched for [existing issues](https://github.com/farion1231/cc-switch/issues), including closed ones.
我已搜索过[已有的 Issue](https://github.com/farion1231/cc-switch/issues),包括已关闭的。
### Related App / 涉及应用
All supported apps / 通用功能
### Problem or Motivation / 问题或动机
Currently, the "Open Terminal" action uses a fixed startup command for each app.
This works for the default workflow, but it is too limited for users who want CC Switch to inject the selected provider environment and then run a custom terminal/session command.
Common examples:
1. Some users manage terminal sessions with Zellij or Tmux, and do not want CC Switch to directly launch the app command. They want CC Switch to open the selected terminal, inject provider environment variables, and then attach/create a session:
```bash
zellij attach --create {sessionName}
tmux new -A -s {sessionName}
```
2. Some Claude Code users need to append startup flags, for example:
```bash
claude --settings {settingsFile} --dangerously-skip-permissions
```
3. Some users launch apps through wrapper commands or aliases:
```bash
hapi claude --settings {settingsFile}
```
At the moment, these workflows require manually re-running commands after the terminal opens, which makes the "Open Terminal" action less useful for session-managed or wrapper-based workflows.
Related issues:
- #2495
- #2508
- #1548
### Proposed Solution / 建议方案
Add an optional provider-level "Terminal startup command" template.
When empty, CC Switch keeps the existing default behavior.
When configured, the existing "Open Terminal" flow should:
1. Use the selected terminal app as configured today, such as Terminal.app, iTerm2, Warp, etc.
2. Apply the selected provider configuration and inject provider environment variables
3. Run the configured command template instead of the built-in default startup command
This keeps terminal selection and startup command customization separate:
- terminal preference controls where the command runs
- terminal startup command controls what runs after the provider environment is loaded
Useful template variables could include:
- `{settingsFile}`: temporary provider config/settings file path
- `{providerId}`: selected provider id
- `{sessionName}`: generated safe session name
- `{app}`: current app type
- `{cwd}`: selected working directory
### Additional Context / 补充信息
Example commands:
```bash
zellij attach --create {sessionName}
tmux new -A -s {sessionName}
claude --settings {settingsFile} --dangerously-skip-permissions
hapi claude --settings {settingsFile}
```
This should be backward compatible: if the command template is empty, each app should continue using its current default startup command.
### Contribution / 参与贡献
- [x] I am interested in contributing to this feature.
我有兴趣参与开发此功能。
Contributor guide
Assessment
This issue has not been assessed yet.