Files
fish-config/functions/_scrollback_prune_junk.fish
T
rootiest db33d9cff7 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
2026-06-03 01:02:55 -04:00

35 lines
1.2 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
function _scrollback_prune_junk --description 'Remove empty, trivial, and Kitty UI noise logs'
set -l dir (set -q SCROLLBACK_HISTORY_DIR; and echo $SCROLLBACK_HISTORY_DIR; or echo "$HOME/.terminal_history")
if set -q argv[1]
set dir $argv[1]
end
test -d $dir || return 0
# Remove any completely empty log file regardless of source
for f in $dir/*.log $dir/*.txt
test -f $f || continue
not test -s $f; and rm $f
end
# Remove any log with only a single meaningful line (e.g. [exited], a lone prompt, or a trivial error)
for f in $dir/*.log $dir/*.txt
test -f $f || continue
set -l line_count (command cat $f | sed 's/\x1b\[[0-9;:]*[a-zA-Z]//g' | grep -cv '^\s*$')
if test $line_count -le 1
rm $f
end
end
# Remove scrollback logs that are Kitty tab-rename prompts (UI noise, not real sessions)
for f in $dir/scrollback_*.log $dir/scrollback_*.txt
test -f $f || continue
if command cat $f | sed 's/\x1b\[[0-9;:]*[a-zA-Z]//g' | grep -q 'Enter the new title for this tab below'
rm $f
end
end
end