fix(config-toggle): exit on Ctrl-C via flag variable, add README tip
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user