From 41e3c19e473b9d8adc1159eebf7c7bc28609a21b Mon Sep 17 00:00:00 2001 From: Stefan Fuertinger Date: Wed, 24 Jun 2026 14:51:19 +0200 Subject: [PATCH 1/2] Fix log-pane for rust-based core-utils Buffering via stdbuf only works with C code using stdio; modern Ubuntu (25.10+) uses a re-write of the core-utils in rust, which stdbuf has no effect on. Updated the log-pane setup to instead rely solely on awk and its built-in fflush() function --- swc-shell-split-window.sh | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/swc-shell-split-window.sh b/swc-shell-split-window.sh index b1d3c58..62f939c 100755 --- a/swc-shell-split-window.sh +++ b/swc-shell-split-window.sh @@ -24,19 +24,36 @@ HISTORY_LINES="${HISTORY_LINES:-5}" # Prompt colour CYAN="[1;36m" +# If awk supports fflush(), use updated streaming command for log pane +if awk 'BEGIN { printf ""; fflush(); exit 0 }' /dev/null 2>&1; then + COMMAND="\ + tail -f '${LOG_FILE}' | + awk -v cyan='${CYAN}' ' + BEGIN { + esc = sprintf(\"%c\", 27) + reset = esc \"[0m\" + } + + /^#/ { next } + + { + printf \"%s%s%d%s %s\n\", esc, cyan, NR, reset, \$0 + fflush() + } + '" +# Fallback to classic stdbuf method +else + COMMAND="\ + tail -f '${LOG_FILE}' | \ + stdbuf -o 0 nl -s'%' -n'ln' -w1 | \ + stdbuf -o0 grep -v '%#' | \ + awk -F'%' '{print \"\033${CYAN}\"\$1\"\033[0m\",\$2}'" +fi + # Create the session to be used # * don't attach yet (-d) # * name it $SESSION (-s "${SESSION}") -tmux new-session -d -s "${SESSION}" "\ - # * start reading the log - tail -f '${LOG_FILE}' | \ - # * extract the line numbers - stdbuf -o 0 nl -s'%' -n'ln' -w1 | \ - # * ignore lines starting with '#' since - # they are the history file's internal timestamps - stdbuf -o 0 grep -v '%#' | \ - # * colour the line numbers - awk -F'%' '{print \"\033${CYAN}\"\$1\"\033[0m\",\$2}'" +tmux new-session -d -s "${SESSION}" "${COMMAND}" # Get the unique (and permanent) ID for the new window WINDOW=$(tmux list-windows -F '#{window_id}' -t "${SESSION}") From c46f7e4015466d6fef29a66b34c7d8c7f53cfbcf Mon Sep 17 00:00:00 2001 From: Stefan Fuertinger Date: Wed, 24 Jun 2026 16:13:25 +0200 Subject: [PATCH 2/2] Included comments in $COMMAND On branch master Changes to be committed: modified: swc-shell-split-window.sh --- swc-shell-split-window.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/swc-shell-split-window.sh b/swc-shell-split-window.sh index 62f939c..242a39b 100755 --- a/swc-shell-split-window.sh +++ b/swc-shell-split-window.sh @@ -27,15 +27,19 @@ CYAN="[1;36m" # If awk supports fflush(), use updated streaming command for log pane if awk 'BEGIN { printf ""; fflush(); exit 0 }' /dev/null 2>&1; then COMMAND="\ + # * start reading the log tail -f '${LOG_FILE}' | awk -v cyan='${CYAN}' ' + # * build escape character and reset sequence for printing BEGIN { esc = sprintf(\"%c\", 27) reset = esc \"[0m\" } - + # * ignore lines starting with # since + # they are internal timestamps of the history file /^#/ { next } - + # * colour the line number, then reset colour and print log line, + # then flush so output appears immediately while tailing { printf \"%s%s%d%s %s\n\", esc, cyan, NR, reset, \$0 fflush() @@ -44,12 +48,19 @@ if awk 'BEGIN { printf ""; fflush(); exit 0 }' /dev/null 2>&1; then # Fallback to classic stdbuf method else COMMAND="\ + # * start reading the log tail -f '${LOG_FILE}' | \ + # * extract the line numbers stdbuf -o 0 nl -s'%' -n'ln' -w1 | \ - stdbuf -o0 grep -v '%#' | \ + # * ignore lines starting with '#' since + # they are the history file's internal timestamps + stdbuf -o 0 grep -v '%#' | \ + # * colour the line numbers awk -F'%' '{print \"\033${CYAN}\"\$1\"\033[0m\",\$2}'" fi +echo $COMMAND + # Create the session to be used # * don't attach yet (-d) # * name it $SESSION (-s "${SESSION}")