From bff084db078f3ba91a2c8be483b129c5a0a71a5f Mon Sep 17 00:00:00 2001 From: rootiest Date: Thu, 11 Jun 2026 01:29:28 -0400 Subject: [PATCH] fix(config-toggle): exit on Ctrl-C via flag variable, add README tip --- README.md | 2 ++ functions/config-toggle.fish | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 491e97b..4bcb657 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/functions/config-toggle.fish b/functions/config-toggle.fish index a110a7e..3966cb4 100644 --- a/functions/config-toggle.fish +++ b/functions/config-toggle.fish @@ -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