fix: guard and document the external tools PR #168 flagged as unguarded

PR #168's Notes section named several functions with a real
external-tool dependency that no `type -q`/`command -q`/`command -v`/
`which` guard covers anywhere in the tree, deliberately left out of
DEPENDENCIES to avoid breaking test_dependencies_resolve. Adds the
guard each was missing, then declares the dependency now that it
resolves:

- bkg, detach: nohup
- gitui: gitui (self-shadow; type -q -f to skip the function itself)
- play-media: mpv, vlc -- already guarded via `type -q -f $p` in a
  loop, just never recognized as one (see next point)
- steam-dl: systemd-inhibit, steam
- wake-lock: systemd-inhibit
- split, spwin, tab: wezterm, konsole (kitty already declared)

docs/verify-manual.py's guard-detection regex only matched `type -q
<name>` immediately, so `type -q -f $p` (the `-f` flag excludes
functions from the match, needed wherever a wrapper shadows a binary
of its own name) was invisible to it -- both as a direct guard and
through the loop-variable indirection. Broadened both patterns to
skip over any flags between `-q` and the name/variable.

split/spwin/tab dispatch on $TERM/$TERM_PROGRAM/$KONSOLE_VERSION to
pick which terminal-specific binary to call, per this repo's C4
convention -- but those env vars only prove the terminal type, not
that its CLI binary is on $PATH: they propagate over ssh, so sshing
out from Kitty/WezTerm inherits the var on a remote host that never
installed the binary. Same latent gap in clone/clonet, whose
clone-in-kitty is a function Kitty's own shell integration injects,
not present on a remote shell that only inherited $TERM. All five now
check the actual thing they are about to call, not just the env var
that selects it.

Also guards and documents three more real, previously-undeclared
dependencies found by the same audit, unrelated to PR #168's named
list but the identical pattern: fast-cli (fast), lock (loginctl),
ports (lsof), screensleep (busctl).

docs/fish-config.md regenerated to match.
This commit is contained in:
2026-09-22 22:40:33 -04:00
parent 3bbda31eff
commit 8dcbc62359
17 changed files with 208 additions and 26 deletions
+49 -11
View File
@@ -1026,11 +1026,13 @@ functions). They are active in all interactive sessions.
Exit Status: Exit Status:
0 Repository cloned 0 Repository cloned
1 Not running inside Kitty terminal 1 Not running inside Kitty terminal, or clone-in-kitty isn't available
Example: Example:
clone https://github.com/user/repo.git clone https://github.com/user/repo.git
**Dependencies:** `clone-in-kitty`
### clonet ### clonet
Synopsis: clonet [args...] Synopsis: clonet [args...]
@@ -1043,11 +1045,13 @@ functions). They are active in all interactive sessions.
Exit Status: Exit Status:
0 Repository cloned 0 Repository cloned
1 Not running inside Kitty terminal 1 Not running inside Kitty terminal, or clone-in-kitty isn't available
Example: Example:
clonet https://github.com/user/repo.git clonet https://github.com/user/repo.git
**Dependencies:** `clone-in-kitty`
## 5.3 Editors and Viewers ## 5.3 Editors and Viewers
### edit ### edit
@@ -1335,9 +1339,17 @@ functions). They are active in all interactive sessions.
Arguments: Arguments:
args... Arguments forwarded to the gitui command args... Arguments forwarded to the gitui command
Exit Status:
1 gitui is not installed
* Exit status of gitui otherwise
Example: Example:
gitui gitui
**Dependencies:** `gitui`
**Used by:** `gitui`
### gitup ### gitup
Synopsis: gitup [args...] Synopsis: gitup [args...]
@@ -1758,11 +1770,14 @@ functions). They are active in all interactive sessions.
Locks the current desktop session using loginctl lock-session. Locks the current desktop session using loginctl lock-session.
Exit Status: Exit Status:
Exit status of loginctl lock-session 1 loginctl is not installed
* Exit status of loginctl lock-session otherwise
Example: Example:
lock lock
**Dependencies:** `loginctl`
### ports ### ports
Synopsis: ports Synopsis: ports
@@ -1771,11 +1786,14 @@ functions). They are active in all interactive sessions.
port numbers and addresses without hostname resolution. port numbers and addresses without hostname resolution.
Exit Status: Exit Status:
Exit status of lsof 1 lsof is not installed
* Exit status of lsof otherwise
Example: Example:
ports ports
**Dependencies:** `lsof`
### sbver ### sbver
Synopsis: sbver [--brief] Synopsis: sbver [--brief]
@@ -1808,11 +1826,14 @@ functions). They are active in all interactive sessions.
PowerDevil "Turn Off Screen" global shortcut via busctl. PowerDevil "Turn Off Screen" global shortcut via busctl.
Exit Status: Exit Status:
Exit status of busctl 1 busctl is not installed
* Exit status of busctl otherwise
Example: Example:
screensleep screensleep
**Dependencies:** `busctl`
### sudo-toggle ### sudo-toggle
Synopsis: sudo-toggle Synopsis: sudo-toggle
@@ -1880,6 +1901,8 @@ functions). They are active in all interactive sessions.
Example: Example:
bkg firefox bkg firefox
**Dependencies:** `nohup`
**Used by:** `md` **Used by:** `md`
### detach ### detach
@@ -1903,6 +1926,8 @@ functions). They are active in all interactive sessions.
Example: Example:
detach rsync -a ./data remote:/backup/ detach rsync -a ./data remote:/backup/
**Dependencies:** `nohup`
### fish_mode_prompt ### fish_mode_prompt
Synopsis: fish_mode_prompt Synopsis: fish_mode_prompt
@@ -2035,7 +2060,7 @@ functions). They are active in all interactive sessions.
split split
split -v nvim README.md split -v nvim README.md
**Dependencies:** `kitty` **Dependencies:** `kitty`, `wezterm`
### spwin ### spwin
@@ -2054,7 +2079,7 @@ functions). They are active in all interactive sessions.
Example: Example:
spwin spwin
**Dependencies:** `kitty` **Dependencies:** `kitty`, `wezterm`
### ssh ### ssh
@@ -2093,7 +2118,7 @@ functions). They are active in all interactive sessions.
Example: Example:
tab tab
**Dependencies:** `kitty` **Dependencies:** `kitty`, `wezterm`, `konsole`
## 5.9 Clipboard ## 5.9 Clipboard
@@ -2181,6 +2206,8 @@ functions). They are active in all interactive sessions.
Example: Example:
fast fast
**Used by:** `fast-cli`
### fast-cli ### fast-cli
Synopsis: fast-cli [args...] Synopsis: fast-cli [args...]
@@ -2190,9 +2217,15 @@ functions). They are active in all interactive sessions.
Arguments: Arguments:
args... Arguments forwarded to the fast command args... Arguments forwarded to the fast command
Exit Status:
1 fast is not installed
* Exit status of fast otherwise
Example: Example:
fast-cli fast-cli
**Dependencies:** `fast`
### gip ### gip
Synopsis: gip Synopsis: gip
@@ -2992,7 +3025,7 @@ functions). They are active in all interactive sessions.
play-media play-media
play-media --player mpv play-media --player mpv
**Dependencies:** `_fzf_preview_media`, `_fzf_wrapper`, `fd`, `fdfind`, `file`, `xdg-mime` **Dependencies:** `_fzf_preview_media`, `_fzf_wrapper`, `fd`, `fdfind`, `file`, `xdg-mime`, `mpv`, `vlc`
### spark ### spark
@@ -3022,11 +3055,14 @@ functions). They are active in all interactive sessions.
or sleeping during active downloads. or sleeping during active downloads.
Exit Status: Exit Status:
Exit status of steam (via systemd-inhibit) 1 systemd-inhibit or steam is not installed
* Exit status of steam (via systemd-inhibit) otherwise
Example: Example:
steam-dl steam-dl
**Dependencies:** `systemd-inhibit`, `steam`
### yt-dlp ### yt-dlp
Synopsis: yt-dlp [args...] URL [URL...] Synopsis: yt-dlp [args...] URL [URL...]
@@ -3615,11 +3651,13 @@ functions). They are active in all interactive sessions.
Exit Status: Exit Status:
0 Command ran and completed 0 Command ran and completed
1 No command provided 1 No command provided, or systemd-inhibit is not installed
Example: Example:
wake-lock rsync -avz src/ dest/ wake-lock rsync -avz src/ dest/
**Dependencies:** `systemd-inhibit`
# 6. DEPENDENCY CATALOG # 6. DEPENDENCY CATALOG
`fish-deps` manages these tools. Run `fish-deps` to check status, `fish-deps` manages these tools. Run `fish-deps` to check status,
+5 -2
View File
@@ -211,12 +211,15 @@ def test_dependencies_resolve():
repo = Path(__file__).parent.parent repo = Path(__file__).parent.parent
functions = _parsed_functions() functions = _parsed_functions()
known = {p.stem for p in (repo / "functions").glob("*.fish")} | set(functions) known = {p.stem for p in (repo / "functions").glob("*.fish")} | set(functions)
guard_re = re.compile(r"(?:type -q|command -q|command -v|which)\s+([\w.\-]+)") # `type` takes its own flags (e.g. `-f` to exclude functions from the
# match, as in `type -q -f $p`) that can sit between `-q` and the name
# -- skip over any of those so the guard is still recognized.
guard_re = re.compile(r"(?:type -q(?:\s+-\w+)*|command -q|command -v|which)\s+([\w.\-]+)")
for path in list(repo.glob("conf.d/*.fish")) + list((repo / "functions").glob("*.fish")): for path in list(repo.glob("conf.d/*.fish")) + list((repo / "functions").glob("*.fish")):
text = path.read_text(encoding="utf-8") text = path.read_text(encoding="utf-8")
known |= set(guard_re.findall(text)) known |= set(guard_re.findall(text))
for var, names in re.findall(r"for\s+(\w+)\s+in\s+([^\n;]+)", text): for var, names in re.findall(r"for\s+(\w+)\s+in\s+([^\n;]+)", text):
if re.search(rf"type -q\s+\$\{{?{re.escape(var)}\}}?\b", text): if re.search(rf"type -q(?:\s+-\w+)*\s+\$\{{?{re.escape(var)}\}}?\b", text):
known |= set(names.split()) known |= set(names.split())
dangling = [] dangling = []
for name, fn in functions.items(): for name, fn in functions.items():
+8
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 08-terminal-management # 08-terminal-management
# #
# DEPENDENCIES
# nohup
#
# SYNOPSIS # SYNOPSIS
# bkg <command> [args...] # bkg <command> [args...]
# #
@@ -32,6 +35,11 @@ function bkg --description 'Execute bkg'
return 1 return 1
end end
if not type -q nohup
echo (set_color red)"Error: nohup is not installed."(set_color normal) >&2
return 1
end
# Run the command using nohup to make it immune to hangups (like closing the terminal). # Run the command using nohup to make it immune to hangups (like closing the terminal).
# Redirect both stdout and stderr to /dev/null to discard all output. # Redirect both stdout and stderr to /dev/null to discard all output.
# The final ampersand (&) sends the entire process to the background. # The final ampersand (&) sends the entire process to the background.
+11 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 02-navigation # 02-navigation
# #
# DEPENDENCIES
# clone-in-kitty
#
# SYNOPSIS # SYNOPSIS
# clone [args...] # clone [args...]
# #
@@ -16,7 +19,7 @@
# #
# EXIT STATUS # EXIT STATUS
# 0 Repository cloned # 0 Repository cloned
# 1 Not running inside Kitty terminal # 1 Not running inside Kitty terminal, or clone-in-kitty isn't available
# #
# EXAMPLE # EXAMPLE
# clone https://github.com/user/repo.git # clone https://github.com/user/repo.git
@@ -25,5 +28,12 @@ function clone --wraps='clone-in-kitty' --description 'alias clone=clone-in-kitt
echo "Error: The 'clone' command requires Kitty terminal." >&2 echo "Error: The 'clone' command requires Kitty terminal." >&2
return 1 return 1
end end
# $TERM only proves the terminal type -- clone-in-kitty is a function
# Kitty's own shell integration injects, which doesn't happen over an
# ssh session that merely inherits $TERM from the local Kitty.
if not type -q clone-in-kitty
echo "Error: 'clone' detected Kitty but clone-in-kitty isn't available (shell integration not loaded)." >&2
return 1
end
clone-in-kitty $argv clone-in-kitty $argv
end end
+11 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 02-navigation # 02-navigation
# #
# DEPENDENCIES
# clone-in-kitty
#
# SYNOPSIS # SYNOPSIS
# clonet [args...] # clonet [args...]
# #
@@ -16,7 +19,7 @@
# #
# EXIT STATUS # EXIT STATUS
# 0 Repository cloned # 0 Repository cloned
# 1 Not running inside Kitty terminal # 1 Not running inside Kitty terminal, or clone-in-kitty isn't available
# #
# EXAMPLE # EXAMPLE
# clonet https://github.com/user/repo.git # clonet https://github.com/user/repo.git
@@ -25,5 +28,12 @@ function clonet --wraps='clone-in-kitty --type=tab' --description 'alias clonet=
echo "Error: The 'clonet' command requires Kitty terminal." >&2 echo "Error: The 'clonet' command requires Kitty terminal." >&2
return 1 return 1
end end
# $TERM only proves the terminal type -- clone-in-kitty is a function
# Kitty's own shell integration injects, which doesn't happen over an
# ssh session that merely inherits $TERM from the local Kitty.
if not type -q clone-in-kitty
echo "Error: 'clonet' detected Kitty but clone-in-kitty isn't available (shell integration not loaded)." >&2
return 1
end
clone-in-kitty --type=tab $argv clone-in-kitty --type=tab $argv
end end
+8
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 08-terminal-management # 08-terminal-management
# #
# DEPENDENCIES
# nohup
#
# SYNOPSIS # SYNOPSIS
# detach [-h] [--version] <command> [args...] # detach [-h] [--version] <command> [args...]
# #
@@ -66,5 +69,10 @@ function detach --description 'Execute detach'
return 1 return 1
end end
if not type -q nohup
echo (set_color red)"Error: nohup is not installed."(set_color normal) >&2
return 1
end
nohup $args >/dev/null 2>&1 & nohup $args >/dev/null 2>&1 &
end end
+11
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 10-network # 10-network
# #
# DEPENDENCIES
# fast
#
# SYNOPSIS # SYNOPSIS
# fast-cli [args...] # fast-cli [args...]
# #
@@ -13,8 +16,16 @@
# ARGUMENTS # ARGUMENTS
# args... Arguments forwarded to the fast command # args... Arguments forwarded to the fast command
# #
# EXIT STATUS
# 1 fast is not installed
# * Exit status of fast otherwise
#
# EXAMPLE # EXAMPLE
# fast-cli # fast-cli
function fast-cli --description "Run a speed test using fast.com" function fast-cli --description "Run a speed test using fast.com"
if not type -q -f fast
echo (set_color red)"Error: fast is not installed."(set_color normal) >&2
return 1
end
command fast $argv command fast $argv
end end
+12 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 04-git-and-version-control # 04-git-and-version-control
# #
# DEPENDENCIES
# gitui
#
# SYNOPSIS # SYNOPSIS
# gitui [args...] # gitui [args...]
# #
@@ -14,9 +17,17 @@
# ARGUMENTS # ARGUMENTS
# args... Arguments forwarded to the gitui command # args... Arguments forwarded to the gitui command
# #
# EXIT STATUS
# 1 gitui is not installed
# * Exit status of gitui otherwise
#
# EXAMPLE # EXAMPLE
# gitui # gitui
function gitui --wraps='gitui' --description 'alias gitui=gitui -t mocha.ron' function gitui --wraps='gitui' --description 'alias gitui=gitui -t mocha.ron'
if not type -q -f gitui
echo (set_color red)"Error: gitui is not installed."(set_color normal) >&2
return 1
end
command gitui -t frappe.ron $argv command gitui -t frappe.ron $argv
end end
+10 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 07-system-and-monitoring # 07-system-and-monitoring
# #
# DEPENDENCIES
# loginctl
#
# SYNOPSIS # SYNOPSIS
# lock # lock
# #
@@ -11,12 +14,18 @@
# Locks the current desktop session using loginctl lock-session. # Locks the current desktop session using loginctl lock-session.
# #
# EXIT STATUS # EXIT STATUS
# Exit status of loginctl lock-session # 1 loginctl is not installed
# * Exit status of loginctl lock-session otherwise
# #
# EXAMPLE # EXAMPLE
# lock # lock
function lock --wraps='loginctl' --description 'alias lock=loginctl' function lock --wraps='loginctl' --description 'alias lock=loginctl'
__fish_help_header (status current-function) $argv; and return 0 __fish_help_header (status current-function) $argv; and return 0
if not type -q loginctl
echo (set_color red)"Error: loginctl is not installed."(set_color normal) >&2
return 1
end
loginctl lock-session loginctl lock-session
end end
+1 -1
View File
@@ -5,7 +5,7 @@
# 13-media-and-utilities # 13-media-and-utilities
# #
# DEPENDENCIES # DEPENDENCIES
# _fzf_preview_media, _fzf_wrapper, fd, fdfind, file, xdg-mime # _fzf_preview_media, _fzf_wrapper, fd, fdfind, file, xdg-mime, mpv, vlc
# #
# SYNOPSIS # SYNOPSIS
# play-media [-p|--player <cmd>] # play-media [-p|--player <cmd>]
+10 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 07-system-and-monitoring # 07-system-and-monitoring
# #
# DEPENDENCIES
# lsof
#
# SYNOPSIS # SYNOPSIS
# ports # ports
# #
@@ -12,12 +15,18 @@
# port numbers and addresses without hostname resolution. # port numbers and addresses without hostname resolution.
# #
# EXIT STATUS # EXIT STATUS
# Exit status of lsof # 1 lsof is not installed
# * Exit status of lsof otherwise
# #
# EXAMPLE # EXAMPLE
# ports # ports
function ports --wraps='sudo' --description 'Show active network listeners' function ports --wraps='sudo' --description 'Show active network listeners'
__fish_help_header (status current-function) $argv; and return 0 __fish_help_header (status current-function) $argv; and return 0
if not type -q lsof
echo (set_color red)"Error: lsof is not installed."(set_color normal) >&2
return 1
end
sudo lsof -iTCP -sTCP:LISTEN -P -n sudo lsof -iTCP -sTCP:LISTEN -P -n
end end
+10 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 07-system-and-monitoring # 07-system-and-monitoring
# #
# DEPENDENCIES
# busctl
#
# SYNOPSIS # SYNOPSIS
# screensleep # screensleep
# #
@@ -12,13 +15,19 @@
# PowerDevil "Turn Off Screen" global shortcut via busctl. # PowerDevil "Turn Off Screen" global shortcut via busctl.
# #
# EXIT STATUS # EXIT STATUS
# Exit status of busctl # 1 busctl is not installed
# * Exit status of busctl otherwise
# #
# EXAMPLE # EXAMPLE
# screensleep # screensleep
function screensleep --description 'Turn off the display using KDE PowerDevil' function screensleep --description 'Turn off the display using KDE PowerDevil'
__fish_help_header (status current-function) $argv; and return 0 __fish_help_header (status current-function) $argv; and return 0
if not type -q busctl
echo (set_color red)"Error: busctl is not installed."(set_color normal) >&2
return 1
end
# Optional: 1-second delay to ensure no keystrokes wake it immediately # Optional: 1-second delay to ensure no keystrokes wake it immediately
sleep 1 sleep 1
busctl --user call \ busctl --user call \
+12 -1
View File
@@ -8,7 +8,7 @@
# integrations/window-mgmt # integrations/window-mgmt
# #
# DEPENDENCIES # DEPENDENCIES
# kitty # kitty, wezterm
# #
# SYNOPSIS # SYNOPSIS
# split [-h | -v] [command...] # split [-h | -v] [command...]
@@ -55,6 +55,17 @@ function split --description 'Run a command in a new terminal split'
return 1 return 1
end end
# $TERM/$TERM_PROGRAM only prove the terminal type, not that its CLI
# binary is on $PATH -- e.g. sshing out from Kitty/WezTerm inherits the
# env var on the remote host without the binary. Check explicitly.
if test $is_kitty -eq 1; and not type -q kitty
echo "Error: 'split' detected Kitty but the kitty binary is not installed." >&2
return 1
else if test $is_wezterm -eq 1; and not type -q wezterm
echo "Error: 'split' detected WezTerm but the wezterm binary is not installed." >&2
return 1
end
set -l kitty_loc hsplit set -l kitty_loc hsplit
set -l wez_loc --bottom set -l wez_loc --bottom
+12 -2
View File
@@ -8,7 +8,7 @@
# integrations/window-mgmt # integrations/window-mgmt
# #
# DEPENDENCIES # DEPENDENCIES
# kitty # kitty, wezterm
# #
# SYNOPSIS # SYNOPSIS
# spwin [args...] # spwin [args...]
@@ -36,13 +36,23 @@ function spwin --wraps='~/.config/kitty/spawn-window.sh' --description 'spawn wi
return 1 return 1
end end
# $TERM/$TERM_PROGRAM only prove the terminal type, not that its CLI
# binary is on $PATH -- e.g. sshing out from Kitty/WezTerm inherits the
# env var on the remote host without the binary. Check explicitly.
if test "$TERM" = xterm-kitty if test "$TERM" = xterm-kitty
if test -x ~/.config/kitty/spawn-window.sh if test -x ~/.config/kitty/spawn-window.sh
~/.config/kitty/spawn-window.sh $argv ~/.config/kitty/spawn-window.sh $argv
else else if type -q kitty
kitty @ launch --type=window $argv kitty @ launch --type=window $argv
else
echo "Error: 'spwin' detected Kitty but neither spawn-window.sh nor the kitty binary is available." >&2
return 1
end end
else if test "$TERM_PROGRAM" = WezTerm else if test "$TERM_PROGRAM" = WezTerm
if not type -q wezterm
echo "Error: 'spwin' detected WezTerm but the wezterm binary is not installed." >&2
return 1
end
wezterm cli spawn $argv wezterm cli spawn $argv
else else
echo "Error: The 'spwin' command requires Kitty or WezTerm." >&2 echo "Error: The 'spwin' command requires Kitty or WezTerm." >&2
+12 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 13-media-and-utilities # 13-media-and-utilities
# #
# DEPENDENCIES
# systemd-inhibit, steam
#
# SYNOPSIS # SYNOPSIS
# steam-dl # steam-dl
# #
@@ -12,13 +15,21 @@
# or sleeping during active downloads. # or sleeping during active downloads.
# #
# EXIT STATUS # EXIT STATUS
# Exit status of steam (via systemd-inhibit) # 1 systemd-inhibit or steam is not installed
# * Exit status of steam (via systemd-inhibit) otherwise
# #
# EXAMPLE # EXAMPLE
# steam-dl # steam-dl
function steam-dl --description 'Run Steam while inhibiting system sleep' function steam-dl --description 'Run Steam while inhibiting system sleep'
__fish_help_header (status current-function) $argv; and return 0 __fish_help_header (status current-function) $argv; and return 0
for cmd in systemd-inhibit steam
if not type -q $cmd
echo (set_color red)"Error: $cmd is not installed."(set_color normal) >&2
return 1
end
end
echo "Inhibiting sleep while Steam downloads..." echo "Inhibiting sleep while Steam downloads..."
systemd-inhibit --why="Active Download" --who="User" --what=idle:sleep steam systemd-inhibit --why="Active Download" --who="User" --what=idle:sleep steam
end end
+17 -1
View File
@@ -8,7 +8,7 @@
# integrations/window-mgmt # integrations/window-mgmt
# #
# DEPENDENCIES # DEPENDENCIES
# kitty # kitty, wezterm, konsole
# #
# SYNOPSIS # SYNOPSIS
# tab [args...] # tab [args...]
@@ -42,11 +42,27 @@ function tab --description 'Spawn a new tab in the current terminal'
set dir "$PWD" set dir "$PWD"
end end
# $TERM/$TERM_PROGRAM/$KONSOLE_VERSION only prove the terminal type,
# not that its CLI binary is on $PATH -- e.g. sshing out from one of
# these inherits the env var on the remote host without the binary.
# Check explicitly.
if test "$TERM" = xterm-kitty if test "$TERM" = xterm-kitty
if not type -q kitty
echo "Error: 'tab' detected Kitty but the kitty binary is not installed." >&2
return 1
end
kitty @ launch --type=tab --cwd="$dir" $argv kitty @ launch --type=tab --cwd="$dir" $argv
else if test "$TERM_PROGRAM" = WezTerm else if test "$TERM_PROGRAM" = WezTerm
if not type -q wezterm
echo "Error: 'tab' detected WezTerm but the wezterm binary is not installed." >&2
return 1
end
wezterm cli spawn --cwd "$dir" $argv wezterm cli spawn --cwd "$dir" $argv
else if set -q KONSOLE_VERSION else if set -q KONSOLE_VERSION
if not type -q konsole
echo "Error: 'tab' detected Konsole but the konsole binary is not installed." >&2
return 1
end
konsole --new-tab --workdir "$dir" $argv konsole --new-tab --workdir "$dir" $argv
else else
echo "Error: No supported terminal found. Try Kitty, WezTerm, or Konsole." >&2 echo "Error: No supported terminal found. Try Kitty, WezTerm, or Konsole." >&2
+9 -1
View File
@@ -4,6 +4,9 @@
# CATEGORY # CATEGORY
# 14-miscellaneous # 14-miscellaneous
# #
# DEPENDENCIES
# systemd-inhibit
#
# SYNOPSIS # SYNOPSIS
# wake-lock <command> [args...] # wake-lock <command> [args...]
# #
@@ -17,7 +20,7 @@
# #
# EXIT STATUS # EXIT STATUS
# 0 Command ran and completed # 0 Command ran and completed
# 1 No command provided # 1 No command provided, or systemd-inhibit is not installed
# #
# EXAMPLE # EXAMPLE
# wake-lock rsync -avz src/ dest/ # wake-lock rsync -avz src/ dest/
@@ -30,6 +33,11 @@ function wake-lock --description 'Run a command while inhibiting system sleep'
return 1 return 1
end end
if not type -q systemd-inhibit
echo (set_color red)"Error: systemd-inhibit is not installed."(set_color normal) >&2
return 1
end
echo "Running '$argv' with sleep inhibition active..." echo "Running '$argv' with sleep inhibition active..."
# --what=idle:sleep prevents the system from auto-sleeping or being suspended # --what=idle:sleep prevents the system from auto-sleeping or being suspended