fix(logging): run paru/yay wrappers in PTY to restore progress bars

Piping through tee caused libalpm to detect a non-TTY stdout and
suppress download progress bars. Switch to script(1) with -q -e -c
which allocates a pseudo-TTY so paru/yay see a real terminal, then
strip ANSI escape sequences from the captured log for readability.
Bump wrapper version to 2 to force regeneration on next shell start.
This commit is contained in:
2026-06-11 22:02:56 -04:00
parent 35e86dcd6e
commit 0cbb7c6892
3 changed files with 36 additions and 11 deletions
+16 -4
View File
@@ -20,7 +20,7 @@ end
set -l _paru_real /usr/bin/paru
set -l _paru_wrapper "$HOME/.local/bin/paru"
set -l _paru_wrapper_version 1
set -l _paru_wrapper_version 2
# Skip entirely if the real paru binary isn't present
test -x $_paru_real; or return
@@ -38,14 +38,24 @@ printf '%s\n' \
'#!/usr/bin/env bash' \
"# paru-wrapper-version: $_paru_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' \
'# Runs paru in a PTY via script(1) so progress bars are preserved,' \
'# then strips escape sequences from the captured log file.' \
'' \
'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"' \
'# Build a safely-quoted command string for script(1).' \
'# script(1) allocates a PTY so paru detects a real terminal and shows progress.' \
'cmd_str="/usr/bin/paru"' \
'for arg in "$@"; do' \
' cmd_str+=" $(printf '"'"'%q'"'"' "$arg")"' \
'done' \
'script -q -e -c "$cmd_str" "$log_file"' \
'exit_code=$?' \
'' \
'# Strip ANSI escape sequences and carriage returns for readable plain-text logs.' \
'sed -i '"'"'s/\x1b\[[0-9;?]*[a-zA-Z]//g; s/\r//g'"'"' "$log_file" 2>/dev/null || true' \
'' \
'max_files="${SCROLLBACK_HISTORY_MAX_FILES:-100}"' \
'mapfile -t logs < <(ls -1t "$log_dir"/paru_*.log 2>/dev/null)' \
@@ -53,6 +63,8 @@ printf '%s\n' \
'for (( i = ${#logs[@]} - 1; i >= ${#logs[@]} - excess && i >= 0; i-- )); do' \
' rm -f "${logs[$i]}"' \
'done' \
'' \
'exit $exit_code' \
> $_paru_wrapper
chmod +x $_paru_wrapper
+16 -4
View File
@@ -20,7 +20,7 @@ end
set -l _yay_real /usr/bin/yay
set -l _yay_wrapper "$HOME/.local/bin/yay"
set -l _yay_wrapper_version 1
set -l _yay_wrapper_version 2
# Skip entirely if the real yay binary isn't present
test -x $_yay_real; or return
@@ -38,14 +38,24 @@ 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' \
'# Runs yay in a PTY via script(1) so progress bars are preserved,' \
'# then strips escape sequences from the captured log file.' \
'' \
'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"' \
'# Build a safely-quoted command string for script(1).' \
'# script(1) allocates a PTY so yay detects a real terminal and shows progress.' \
'cmd_str="/usr/bin/yay"' \
'for arg in "$@"; do' \
' cmd_str+=" $(printf '"'"'%q'"'"' "$arg")"' \
'done' \
'script -q -e -c "$cmd_str" "$log_file"' \
'exit_code=$?' \
'' \
'# Strip ANSI escape sequences and carriage returns for readable plain-text logs.' \
'sed -i '"'"'s/\x1b\[[0-9;?]*[a-zA-Z]//g; s/\r//g'"'"' "$log_file" 2>/dev/null || true' \
'' \
'max_files="${SCROLLBACK_HISTORY_MAX_FILES:-100}"' \
'mapfile -t logs < <(ls -1t "$log_dir"/yay_*.log 2>/dev/null)' \
@@ -53,6 +63,8 @@ printf '%s\n' \
'for (( i = ${#logs[@]} - 1; i >= ${#logs[@]} - excess && i >= 0; i-- )); do' \
' rm -f "${logs[$i]}"' \
'done' \
'' \
'exit $exit_code' \
> $_yay_wrapper
chmod +x $_yay_wrapper
+4 -3
View File
@@ -216,7 +216,8 @@ scrollback snapshot to SCROLLBACK_HISTORY_DIR. Files are named:
scrollback_YYYY-MM-DD_HH-MM-SS.log
The paru and yay wrappers (auto-generated in ~/.local/bin/) tee all output to:
The paru and yay wrappers (auto-generated in ~/.local/bin/) run inside a PTY
via script(1) so progress bars are preserved, and capture all output to:
paru_YYYY-MM-DD_HH-MM-SS.log
yay_YYYY-MM-DD_HH-MM-SS.log
@@ -1615,9 +1616,9 @@ __fish_config_op_logging skips all capture and removes the logging wrappers.
───────────────────────────────────────────────────────────────────────────
Scrollback capture Terminal session output saved to:
~/.terminal_history/scrollback_YYYY-MM-DD_HH-MM-SS.log
paru wrapper All paru/AUR output teed to:
paru wrapper All paru/AUR output captured to:
~/.terminal_history/paru_YYYY-MM-DD_HH-MM-SS.log
yay wrapper All yay/AUR output teed to:
yay wrapper All yay/AUR output captured to:
~/.terminal_history/yay_YYYY-MM-DD_HH-MM-SS.log
Kitty watcher watcher.py captures scrollback when Kitty closes