Files
rootiest 084e6fb9ca refactor(functions): standardize documentation, metadata, and wrappers
- Add comprehensive `--description` flags to all fish functions for better `help` and `functions` output.
- Introduce and correct `--wraps` flags to ensure proper completions for aliased commands (e.g., `top` wrapping `btop`, `zellij`, `upgrade` wrapping `paru`).
- Prepend descriptive comments before function definitions for better source readability.
- Add standard copyright and SPDX license identifiers to shell scripts.
- Enhance script robustness by ensuring consistent terminal checks (Kitty, WezTerm) and graceful fallbacks in window/tab spawning functions (`spwin`, `tab`).
- Implement graceful fallbacks to basic core utilities when preferred modern alternatives are missing (e.g., `top` falling back to system `top` if `btop` is missing, `view` falling back to `less` or `cat` if `nvim` is unavailable).
- Improve overall code consistency across the `functions/` directory.
2026-04-30 23:16:28 -04:00

53 lines
2.2 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# Run Bash commands replaying changes in Fish
function replay --description 'Run Bash commands replaying changes in Fish'
switch "$argv"
case -v --version
echo "replay, version 1.2.1"
case "" -h --help
echo "Usage: replay <commands> Run Bash commands replaying changes in Fish"
echo "Options:"
echo " -v or --version Print version"
echo " -h or --help Print this help message"
case \*
set --local env
set --local sep @$fish_pid(random)(command date +%s)
set --local argv $argv[1] (string escape -- $argv[2..-1])
set --local out (command bash -c "
$argv
status=\$?
[ \$status -gt 0 ] && exit \$status
command compgen -e | command awk -v sep=$sep '{
gsub(/\n/, \"\\\n\", ENVIRON[\$0])
print \$0 sep ENVIRON[\$0]
}' && alias
") || return
string replace --all -- \\n \n (
for line in $out
if string split -- $sep $line | read --local --line name value
set --append env $name
contains -- $name SHLVL PS1 BASH_FUNC || test "$$name" = "$value" && continue
if test "$name" = PATH
echo set PATH (string split -- : $value | string replace --regex --all -- '(^.*$)' '"$1"')
else if test "$name" = PWD
echo builtin cd "\"$value\""
else
echo "set --global --export $name "(string escape -- $value)
end
else
set --query env[1] && string match --entire --regex -- "^alias" $line || echo "echo \"$line\""
end
end | string replace --all -- \$ \\\$
for name in (set --export --names)
contains -- $name $env || echo "set --erase $name"
end
) | source
end
end