feat(shell): enhance log browser, add yay wrapper, and integrate starship OSC prompt markers

- logs.fish: add yay category, ov-powered viewing for paru/yay (section
  headers, color highlights, ==> AUR build markers) and scrollback logs
  (OSC 133;A sticky prompt headers); add fzf Ctrl-D delete with Y/n
  confirm and list refresh, ? toggleable help overlay; run
  _scrollback_prune_junk before building file list
- _scrollback_prune_junk: new utility to remove empty, single-line, and
  Kitty tab-rename noise logs before display and before max-file pruning;
  called from both logs and smart_exit
- smart_exit: call _scrollback_prune_junk before counting toward max files
- conf.d/yay-wrapper.fish: auto-generate ~/.local/bin/yay logging wrapper
  mirroring paru-wrapper; tees output to timestamped logs, prunes old ones
- conf.d/starship.fish: move fish_prompt from config.fish; emit OSC 133;A
  after the prompt's leading newline so the marker lands on the info-bar
  line rather than the blank line above it; guard with type -q starship so
  clean fish sessions use built-in markers unchanged
- config.fish: remove inline fish_prompt block (now in conf.d/starship.fish);
  add return sentinel at EOF to prevent tool-injected init lines from running
- completions/ov.fish: add ov tab completions
- README.md: document all of the above
This commit is contained in:
2026-06-03 01:02:55 -04:00
parent 3bc28fd9d5
commit db33d9cff7
8 changed files with 436 additions and 16 deletions
+26
View File
@@ -0,0 +1,26 @@
# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Defines fish_prompt only when starship is installed.
# Without starship, fish's built-in prompt already emits OSC 133;A
# on the prompt line itself, so no wrapper is needed.
type -q starship; or return
function fish_prompt
set -l last_status $status
# Blank line between output and next prompt, skipped at the top of a cleared screen
if not test "$fish_private_mode" = true; and test (commandline) = ""
echo
end
# OSC 133;A here (after the blank line) puts the marker on the prompt line itself,
# not the blank line — required for ov's section-delimiter to pin the right line.
printf "\x1b]133;A\x07"
set -g STARSHIP_CMD_STATUS $last_status
command starship prompt --status=$last_status --pipestatus=$pipestatus --jobs=(count (jobs -p))
printf "\x1b]133;B\x07"
end
+47
View File
@@ -0,0 +1,47 @@
# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Generates ~/.local/bin/yay on first run (and on version bump) when
# /usr/bin/yay is installed. The wrapper tees yay output to a
# timestamped log file and prunes old logs, mirroring smart_exit behavior.
set -l _yay_real /usr/bin/yay
set -l _yay_wrapper "$HOME/.local/bin/yay"
set -l _yay_wrapper_version 1
# Skip entirely if the real yay binary isn't present
test -x $_yay_real; or return
# Check if wrapper already exists at the expected version
if test -f $_yay_wrapper
and grep -q "# yay-wrapper-version: $_yay_wrapper_version" $_yay_wrapper 2>/dev/null
set --erase _yay_real _yay_wrapper _yay_wrapper_version
return
end
mkdir -p (dirname $_yay_wrapper)
printf '%s\n' \
'#!/usr/bin/env bash' \
"# yay-wrapper-version: $_yay_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
set --erase _yay_real _yay_wrapper _yay_wrapper_version