e651566e14
RETURNS previously conflated fish's $status exit code with genuine stdout/printed output, e.g. rm listing "0/1" as if they were print values rather than exit codes. Rename RETURNS to EXIT STATUS across all 83 documented functions, and reintroduce RETURNS as a distinct label reserved for the 15 functions that actually print to stdout. Update build-manual.py's ENTRY_HEADS to render Exit Status before Returns, manualtools.py's SECTIONS constant, and AGENTS.md's label order and label-usage guidance to match. Add two verify-manual.py regression tests: EXIT STATUS bodies must never contain stray stdout/printed language, and Returns: must always render after Exit Status: when both are present. Regenerate docs/fish-config.md.
109 lines
4.3 KiB
Fish
109 lines
4.3 KiB
Fish
# Copyright (C) 2026 Rootiest
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# SYNOPSIS
|
|
# __fish_config_sync_logging
|
|
#
|
|
# DESCRIPTION
|
|
# Synchronises C5 logging state: creates or removes the Kitty sentinel
|
|
# file ($XDG_CONFIG_HOME/fish/.logging_disabled), generates or removes the
|
|
# paru/yay AUR-helper log wrappers, and starts or stops tmux pipe-pane
|
|
# capture for the current pane — all based on the combined value of
|
|
# __fish_config_opinionated (master) and __fish_config_op_logging (C5).
|
|
# Called by --on-variable event handlers whenever either variable changes.
|
|
# Safe to call at any time; wrapper removal only affects files bearing
|
|
# the generated version-marker comment.
|
|
#
|
|
# EXIT STATUS
|
|
# 0 Always
|
|
#
|
|
# EXAMPLE
|
|
# __fish_config_sync_logging
|
|
function __fish_config_sync_logging --description 'Sync C5 logging state: sentinel file, paru/yay wrappers, and tmux pipe-pane'
|
|
set -l config_home $XDG_CONFIG_HOME
|
|
if test -z "$config_home"
|
|
set config_home "$HOME/.config"
|
|
end
|
|
set -l sentinel "$config_home/fish/.logging_disabled"
|
|
set -l paru_wrapper "$HOME/.local/bin/paru"
|
|
set -l yay_wrapper "$HOME/.local/bin/yay"
|
|
set -l wrapper_version 1
|
|
|
|
if __fish_config_op_enabled __fish_config_op_logging
|
|
# Logging enabled: remove sentinel and regenerate wrappers if binaries exist
|
|
rm -f $sentinel
|
|
|
|
# Restart tmux pipe-pane for the current pane if inside tmux
|
|
_tmux_pipe_log
|
|
|
|
if test -x /usr/bin/paru
|
|
mkdir -p (dirname $paru_wrapper)
|
|
printf '%s\n' \
|
|
'#!/usr/bin/env bash' \
|
|
"# paru-wrapper-version: $wrapper_version" \
|
|
'# Auto-generated by conf.d/paru-wrapper.fish — do not edit by hand.' \
|
|
'# Tees paru output to a timestamped log file and prunes old ones.' \
|
|
'set -o pipefail' \
|
|
'' \
|
|
'log_dir="${SCROLLBACK_HISTORY_DIR:-$HOME/.terminal_history}"' \
|
|
'mkdir -p "$log_dir"' \
|
|
'log_file="$log_dir/paru_$(date +%Y-%m-%d_%H-%M-%S).log"' \
|
|
'' \
|
|
'/usr/bin/paru "$@" 2>&1 | tee "$log_file"' \
|
|
'' \
|
|
'max_files="${SCROLLBACK_HISTORY_MAX_FILES:-100}"' \
|
|
'mapfile -t logs < <(ls -1t "$log_dir"/paru_*.log 2>/dev/null)' \
|
|
'excess=$(( ${#logs[@]} - max_files ))' \
|
|
'for (( i = ${#logs[@]} - 1; i >= ${#logs[@]} - excess && i >= 0; i-- )); do' \
|
|
' rm -f "${logs[$i]}"' \
|
|
'done' \
|
|
>$paru_wrapper
|
|
chmod +x $paru_wrapper
|
|
end
|
|
|
|
if test -x /usr/bin/yay
|
|
mkdir -p (dirname $yay_wrapper)
|
|
printf '%s\n' \
|
|
'#!/usr/bin/env bash' \
|
|
"# yay-wrapper-version: $wrapper_version" \
|
|
'# Auto-generated by conf.d/yay-wrapper.fish — do not edit by hand.' \
|
|
'# Tees yay output to a timestamped log file and prunes old ones.' \
|
|
'set -o pipefail' \
|
|
'' \
|
|
'log_dir="${SCROLLBACK_HISTORY_DIR:-$HOME/.terminal_history}"' \
|
|
'mkdir -p "$log_dir"' \
|
|
'log_file="$log_dir/yay_$(date +%Y-%m-%d_%H-%M-%S).log"' \
|
|
'' \
|
|
'/usr/bin/yay "$@" 2>&1 | tee "$log_file"' \
|
|
'' \
|
|
'max_files="${SCROLLBACK_HISTORY_MAX_FILES:-100}"' \
|
|
'mapfile -t logs < <(ls -1t "$log_dir"/yay_*.log 2>/dev/null)' \
|
|
'excess=$(( ${#logs[@]} - max_files ))' \
|
|
'for (( i = ${#logs[@]} - 1; i >= ${#logs[@]} - excess && i >= 0; i-- )); do' \
|
|
' rm -f "${logs[$i]}"' \
|
|
'done' \
|
|
>$yay_wrapper
|
|
chmod +x $yay_wrapper
|
|
end
|
|
else
|
|
# Logging disabled: create sentinel and remove any generated wrappers
|
|
mkdir -p (dirname $sentinel)
|
|
touch $sentinel
|
|
|
|
if test -f $paru_wrapper
|
|
and grep -q "# paru-wrapper-version:" $paru_wrapper 2>/dev/null
|
|
rm -f $paru_wrapper
|
|
end
|
|
|
|
if test -f $yay_wrapper
|
|
and grep -q "# yay-wrapper-version:" $yay_wrapper 2>/dev/null
|
|
rm -f $yay_wrapper
|
|
end
|
|
|
|
# Stop tmux pipe-pane for the current pane if inside tmux
|
|
if set -q TMUX
|
|
tmux pipe-pane 2>/dev/null
|
|
end
|
|
end
|
|
end
|