diff --git a/conf.d/paru-wrapper.fish b/conf.d/paru-wrapper.fish index 2bb7de5..178af4c 100644 --- a/conf.d/paru-wrapper.fish +++ b/conf.d/paru-wrapper.fish @@ -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 diff --git a/conf.d/yay-wrapper.fish b/conf.d/yay-wrapper.fish index 4e16e05..0d63469 100644 --- a/conf.d/yay-wrapper.fish +++ b/conf.d/yay-wrapper.fish @@ -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 diff --git a/docs/fish-config.md b/docs/fish-config.md index a24b2c4..aaeafed 100644 --- a/docs/fish-config.md +++ b/docs/fish-config.md @@ -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