feat(help): header-driven --help for terminal and session functions

spwin, tab, hist, bkg, wake-lock and fc take the standard first-arg-only
call site, so `wake-lock rsync --help` still runs rsync.

split takes --help only: its own ARGUMENTS documents -h as --horizontal,
so a literal test replaces the renderer's own flag check. Verified that
`split -h` still selects a horizontal split and never prints help.
This commit is contained in:
2026-09-07 20:07:25 -04:00
parent 3399149cba
commit 3d826c5407
7 changed files with 16 additions and 0 deletions
+2
View File
@@ -23,6 +23,8 @@
# EXAMPLE
# bkg firefox
function bkg --description 'Execute bkg'
__fish_help_header (status current-function) $argv; and return 0
# Check if a command was provided as an argument.
if test -z "$argv[1]"
set -l c_head (set_color --bold cyan)
+2
View File
@@ -24,6 +24,8 @@
# fc
# fc git
function fc --description 'Edit and execute the last command (Bash-style fc)'
__fish_help_header (status current-function) $argv; and return 0
set -l tmpfile (mktemp /tmp/fish_fc.XXXXXX).fish
if count $argv >/dev/null
+2
View File
@@ -17,6 +17,8 @@
# EXAMPLE
# hist
function hist --description 'Search fish history and put it in the prompt'
__fish_help_header (status current-function) $argv; and return 0
# Opinionated guard (C4): integrations disabled
if not __fish_config_op_enabled (status current-function)
set -l c_err (set_color red)
+4
View File
@@ -29,6 +29,10 @@
# split
# split -v nvim README.md
function split --description 'Run a command in a new terminal split'
# -h is --horizontal here (see this function's own ARGUMENTS),
# so only the long form may reach the renderer.
test "$argv[1]" = --help; and __fish_help_header (status current-function) --help; and return 0
# Opinionated guard (C4): integrations disabled
if not __fish_config_op_enabled (status current-function)
set -l c_err (set_color red)
+2
View File
@@ -24,6 +24,8 @@
# EXAMPLE
# spwin
function spwin --wraps='~/.config/kitty/spawn-window.sh' --description 'spawn window in kitty or wezterm'
__fish_help_header (status current-function) $argv; and return 0
# Opinionated guard (C4): integrations disabled
if not __fish_config_op_enabled (status current-function)
set -l c_err (set_color red)
+2
View File
@@ -25,6 +25,8 @@
# EXAMPLE
# tab
function tab --description 'Spawn a new tab in the current terminal'
__fish_help_header (status current-function) $argv; and return 0
# Opinionated guard (C4): integrations disabled
if not __fish_config_op_enabled (status current-function)
set -l c_err (set_color red)
+2
View File
@@ -22,6 +22,8 @@
# EXAMPLE
# wake-lock rsync -avz src/ dest/
function wake-lock --description 'Run a command while inhibiting system sleep'
__fish_help_header (status current-function) $argv; and return 0
if test (count $argv) -eq 0
set -l c_head (set_color --bold cyan)
set -l c_cmd (set_color --bold)