Skip to content

refactor: source variables.sh in toggle scripts instead of hardcoding option keys - #8

Merged
danyim merged 1 commit into
masterfrom
refactor/source-variables-in-toggle-scripts
Jun 16, 2026
Merged

refactor: source variables.sh in toggle scripts instead of hardcoding option keys#8
danyim merged 1 commit into
masterfrom
refactor/source-variables-in-toggle-scripts

Conversation

@danyim

@danyim danyim commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Why?

toggle_on.sh and toggle_off.sh hardcoded all tmux option key names as raw strings (@remote-saved-status-left, @remote-indicator-text, etc.), duplicating values already defined in variables.sh. A rename in variables.sh would require manual updates in both scripts with nothing catching the drift.

How?

Both scripts now set CURRENT_DIR and source variables.sh, referencing option keys through the canonical variable names. A new saved_status_left_option variable is added to variables.sh to give the save/restore key a single home.

… option keys

toggle_on.sh and toggle_off.sh previously hardcoded @remote-saved-status-left
and the three @remote-indicator-* option names as raw strings. Any rename in
variables.sh would require manual updates in both scripts with no static check
to catch drift.

Both scripts now set CURRENT_DIR and source variables.sh, using the canonical
variable names (saved_status_left_option, indicator_text_option, etc.) defined
there. A new saved_status_left_option variable is added to variables.sh to give
the save/restore key a single source of truth.
@danyim
danyim force-pushed the refactor/source-variables-in-toggle-scripts branch from e6355c2 to f14dadb Compare June 16, 2026 22:30
@danyim
danyim requested a review from Copilot June 16, 2026 22:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the tmux toggle scripts to avoid hardcoded option key strings by sourcing scripts/variables.sh and reusing the canonical option-key variables, reducing drift risk when option names change.

Changes:

  • Add saved_status_left_option to scripts/variables.sh as the canonical key for storing/restoring status-left.
  • Update scripts/toggle_on.sh and scripts/toggle_off.sh to compute CURRENT_DIR, source variables.sh, and use the named option-key variables.
  • Document the refactor in CHANGELOG.md.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
scripts/variables.sh Adds a canonical option-key variable for saved status-left.
scripts/toggle_on.sh Sources variables.sh and replaces hardcoded option keys with variables.
scripts/toggle_off.sh Sources variables.sh and replaces hardcoded option keys with variables.
CHANGELOG.md Notes the refactor to centralized option-key variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danyim
danyim merged commit bab8349 into master Jun 16, 2026
2 checks passed
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.

2 participants