feat(shell): replace pager with ov, add logs browser, and auto-generate paru wrapper
- Set $PAGER to ov in config.fish (falls back to less); remove LESS=-R - Rewrite less wrapper with full hierarchy: $PAGER → ov → less → more → cat - Simplify view.fish fallback to delegate to the less wrapper - Add logs function: fzf browser for scrollback and paru logs, opens in $PAGER - Add claude wrapper: auto-injects --remote-control unless already present - Add conf.d/paru-wrapper.fish: generates ~/.local/bin/paru on first run, versioned so future template changes auto-propagate on next shell start - Sync README.md and requirements.md to document all of the above
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function claude --wraps='claude --remote-control' --description 'claude with --remote-control always enabled'
|
||||
if contains -- --remote-control $argv
|
||||
command claude $argv
|
||||
else
|
||||
command claude --remote-control $argv
|
||||
end
|
||||
end
|
||||
+10
-5
@@ -1,11 +1,16 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# alias less=most
|
||||
function less --wraps='most' --description 'alias less=most'
|
||||
if which most >/dev/null 2>&1
|
||||
most $argv
|
||||
else
|
||||
function less --wraps='ov' --description 'Pager wrapper: $PAGER → ov → less → more → cat'
|
||||
if set -q PAGER; and command -q $PAGER
|
||||
command $PAGER $argv
|
||||
else if command -q ov
|
||||
command ov $argv
|
||||
else if command -q less
|
||||
command less $argv
|
||||
else if command -q more
|
||||
command more $argv
|
||||
else
|
||||
command cat $argv
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
function logs --description 'Browse terminal log files interactively with fzf'
|
||||
set -l options h/help c/category=
|
||||
argparse $options -- $argv
|
||||
or return 1
|
||||
|
||||
if set -q _flag_help
|
||||
set -l c_accent (set_color green)
|
||||
set -l c_primary (set_color cyan)
|
||||
set -l c_bold (set_color --bold)
|
||||
set -l c_reset (set_color normal)
|
||||
echo "Usage: "$c_accent"logs"$c_reset" ["$c_primary"OPTIONS"$c_reset"]"
|
||||
echo ""
|
||||
echo "Browse and open terminal log files interactively."
|
||||
echo "Logs sorted newest-first. Type to fuzzy-filter by date or category."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " "$c_primary"-h, --help"$c_reset" Show this help"
|
||||
echo " "$c_primary"-c, --category"$c_reset" Limit to one category: scrollback, paru"
|
||||
echo ""
|
||||
echo "Keys in fzf:"
|
||||
echo " "$c_primary"Enter"$c_reset" Open in \$PAGER"
|
||||
echo " "$c_primary"Ctrl-E"$c_reset" Open in \$EDITOR"
|
||||
echo " "$c_primary"Ctrl-C"$c_reset" Quit"
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l log_dir (set -q SCROLLBACK_HISTORY_DIR; and echo $SCROLLBACK_HISTORY_DIR; or echo "$HOME/.terminal_history")
|
||||
set -l editor (set -q EDITOR; and echo $EDITOR; or echo nvim)
|
||||
|
||||
# Scan primary dir and the legacy kitty dir (deduped)
|
||||
set -l scan_dirs $log_dir
|
||||
set -l legacy_dir "$HOME/.terminal_history"
|
||||
if test -d $legacy_dir; and not contains $legacy_dir $scan_dirs
|
||||
set -a scan_dirs $legacy_dir
|
||||
end
|
||||
|
||||
# Collect entries: "SORTKEY|FILEPATH|CATEGORY"
|
||||
set -l entries
|
||||
for dir in $scan_dirs
|
||||
test -d $dir || continue
|
||||
for f in $dir/*.log $dir/*.txt
|
||||
test -f $f || continue
|
||||
set -l base (string replace -r '\.(log|txt)$' '' (basename $f))
|
||||
set -l ts (string match -r '[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}' $base)
|
||||
test -n "$ts" || continue
|
||||
set -l cat (string replace "_$ts" '' $base)
|
||||
if set -q _flag_category; and test $cat != $_flag_category
|
||||
continue
|
||||
end
|
||||
set -a entries "$ts|$f|$cat"
|
||||
end
|
||||
end
|
||||
|
||||
if test (count $entries) -eq 0
|
||||
echo "No log files found"
|
||||
return 1
|
||||
end
|
||||
|
||||
# Sort newest-first (ISO timestamp prefix is lexicographically correct)
|
||||
set -l sorted (printf '%s\n' $entries | sort -r)
|
||||
|
||||
# Build fzf input lines: "FILEPATH<TAB>DATETIME [CATEGORY]"
|
||||
# Field 1 (hidden via --with-nth 2) = filepath for use in {1} placeholders
|
||||
set -l fzf_lines
|
||||
for entry in $sorted
|
||||
set -l parts (string split '|' $entry)
|
||||
set -l ts_parts (string split '_' $parts[1])
|
||||
set -l date $ts_parts[1]
|
||||
set -l time (string replace -ra '-' ':' $ts_parts[2])
|
||||
|
||||
# Declare before switch so the variable survives past the block
|
||||
set -l label "[$parts[3]]"
|
||||
switch $parts[3]
|
||||
case scrollback
|
||||
set label (printf '\033[36m[scrollback]\033[0m')
|
||||
case paru
|
||||
set label (printf '\033[32m[paru ]\033[0m')
|
||||
end
|
||||
|
||||
set -a fzf_lines (printf '%s\t%s %s %s' $parts[2] $date $time $label)
|
||||
end
|
||||
|
||||
set -l selected (printf '%s\n' $fzf_lines | fzf \
|
||||
--ansi \
|
||||
--delimiter '\t' \
|
||||
--with-nth 2 \
|
||||
--preview 'command cat {1}' \
|
||||
--preview-window 'right:60%:wrap' \
|
||||
--prompt 'Terminal Logs -> ' \
|
||||
--header 'Enter: View Ctrl-E: Edit Ctrl-C: Quit (type to filter by date or category)' \
|
||||
--bind "ctrl-e:execute($editor {1})")
|
||||
|
||||
test -n "$selected" || return 0
|
||||
|
||||
set -l file (echo $selected | cut -f1)
|
||||
test -f $file || return 1
|
||||
if command -q $PAGER
|
||||
command cat $file | command $PAGER
|
||||
else
|
||||
command cat $file
|
||||
end
|
||||
end
|
||||
@@ -42,7 +42,10 @@ function smart_exit --description 'Capture colorized scrollback before exiting,
|
||||
# we check if it contains the phrase "exit" to match 'exit -n' or 'exit --help'.
|
||||
if string match -qr exit "$_"
|
||||
if not string match -qr '^(nvim|vim|vi|nano|emacs|tmux)$' "$active_tui"
|
||||
# Capture the log via the shell
|
||||
kitty @ get-text --match id:$KITTY_WINDOW_ID --extent all --ansi | sed 's/^\[38;2;[0-9;]*m//g' >$filename 2>/dev/null
|
||||
# Broadcast a window variable flag telling Kitty the log is handled
|
||||
kitty @ set-user-vars "logged_by_shell=true" 2>/dev/null
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+1
-3
@@ -5,10 +5,8 @@
|
||||
function view --wraps='nvim -R' --description 'alias view=nvim -R'
|
||||
if type -q nvim
|
||||
nvim -R $argv
|
||||
else if type -q less
|
||||
less $argv
|
||||
else
|
||||
command cat $argv
|
||||
less $argv
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user