Skip to content

Add --config flag for custom settings file path#166

Open
stuartc wants to merge 3 commits intosirmalloc:mainfrom
stuartc:config-flag
Open

Add --config flag for custom settings file path#166
stuartc wants to merge 3 commits intosirmalloc:mainfrom
stuartc:config-flag

Conversation

@stuartc
Copy link

@stuartc stuartc commented Feb 9, 2026

Summary

Adds a --config <path> flag that lets users point ccstatusline at an alternative settings file. This is handy when you want distinct status line configurations for different Claude Code instances (e.g. per-project or per-workspace).

  • --config CLI flag — parsed early in main() and wired through initConfigPath() / getConfigPath() / isCustomConfigPath() in config.ts
  • Install command awareness — when a custom config path is active, the Claude Code install command gets --config <path> appended automatically, with shell-safe quoting for paths containing spaces or special characters
  • isKnownCommand() helper — replaces the duplicated array-of-known-commands pattern and correctly matches both bare commands and commands with a --config suffix
  • TUI indicator — shows the active config path below the header when a custom path is in use, so it's always clear which file you're editing

Test plan

  • New test suite for initConfigPath / getConfigPath / isCustomConfigPath (config-dir.test.ts)
  • New test suite for isKnownCommand and buildCommand via installStatusLine (claude-settings.test.ts)
  • All 20 new tests passing
  • Manual: run bun run start -- --config /tmp/test-settings.json, confirm TUI shows the path and saves to the right file
  • Manual: install to Claude Code from TUI with a custom config path, confirm the command includes --config

Allow users to specify an alternative settings file via `--config <path>`,
enabling distinct status line configs for different Claude Code instances.

- Add initConfigPath/getConfigPath/isCustomConfigPath to config.ts
- Fix backup path to always append .bak instead of replacing .json suffix
- Use path.dirname(SETTINGS_PATH) instead of CONFIG_DIR for mkdir
- Parse --config arg in ccstatusline.ts main() entry point
- Add tests for config path management
When a custom config path is active, the install-to-Claude-Code feature
now appends --config <path> to the status line command. Also updates
isInstalled detection to recognize commands with the --config suffix.

- Add isKnownCommand() to deduplicate command-matching logic
- Add shell-safe path quoting for --config values with spaces/special chars
- Add buildCommand() to append --config when custom path is active
- Refactor isInstalled() to use isKnownCommand()
- Use isKnownCommand() in App.tsx install flow
- Add tests for isKnownCommand() and buildCommand() with CLAUDE_CONFIG_DIR safety net
When a custom --config path is active, display it below the title bar
so users can see which settings file is being edited.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments