fix(config-toggle): exit on Ctrl-C via flag variable, add README tip

This commit is contained in:
2026-06-11 01:29:28 -04:00
parent f75d64bf9c
commit bff084db07
2 changed files with 9 additions and 1 deletions
+2
View File
@@ -198,6 +198,8 @@ set -Ue __fish_config_op_greeting
Command shadows react immediately; bindings, prompt, and abbreviations take effect in new shells. With aliases disabled, `rm` deletes permanently again instead of trashing. See `help config opinionated` for the full component list.
> **Tip:** Run `config-toggle` for an interactive TUI to toggle these settings without typing variable names.
---
## Attribution
+7 -1
View File
@@ -75,7 +75,7 @@ function config-toggle --description 'Interactive TUI for toggling opinionated c
# ── Terminal setup ────────────────────────────────────
printf '\e[?25l' # hide cursor
trap 'printf "\e[?25h"; printf "\n"' INT
trap 'printf "\e[?25h"; set -g __config_toggle_exit 1' INT
# ── Initial draw ──────────────────────────────────────
__config_toggle_draw $cur_row $cur_scope $vars
@@ -86,6 +86,12 @@ function config-toggle --description 'Interactive TUI for toggling opinionated c
# sends 1 byte and read -k 3 returns at once with a 1-char string.
# Arrow keys send the 3-byte sequence ESC [ A/B, matched as \e\[A / \e\[B.
while true
# Check for Ctrl-C signal (trap sets this flag)
if set -q __config_toggle_exit
set -eg __config_toggle_exit
break
end
read -k 3 -l key
switch $key