detached b6aa4da

refactor(helpers): optimize logging display with improved ANSI output handling

commit
b6aa4da6a21d602daaebc141f2dd3ecf0d12b0d2
author
bnema · · 2025-10-20 16:08 UTC
parent
750c2c1
signature
unsigned
1 file · +5 -11
M install/helpers/logging.sh +5 -11
@@ -9,43 +9,37 @@ monitor_pid=""
99 start_log_output() {
1010 local ANSI_SAVE_CURSOR="\033[s"
1111 local ANSI_RESTORE_CURSOR="\033[u"
12- local ANSI_CLEAR_LINE="\033[2K"
12+ local ANSI_CLEAR_BELOW="\033[0J"
1313 local ANSI_HIDE_CURSOR="\033[?25l"
1414 local ANSI_RESET="\033[0m"
1515 local ANSI_GRAY="\033[90m"
1616
17- # Save cursor position and hide cursor
1817 printf $ANSI_SAVE_CURSOR
1918 printf $ANSI_HIDE_CURSOR
2019
21- # Start background monitor process
2220 (
2321 local log_lines=20
2422 local max_line_width=$((LOGO_WIDTH - 4))
2523
2624 while true; do
27- # Read the last N lines into an array
2825 mapfile -t current_lines < <(tail -n $log_lines "$ARCHUP_INSTALL_LOG_FILE" 2>/dev/null)
2926
30- # Build complete output buffer with escape sequences
31- output=""
27+ printf "${ANSI_RESTORE_CURSOR}${ANSI_CLEAR_BELOW}"
28+
3229 for ((i = 0; i < log_lines; i++)); do
3330 line="${current_lines[i]:-}"
3431
35- # Truncate if needed
3632 if [ ${#line} -gt $max_line_width ]; then
3733 line="${line:0:$max_line_width}..."
3834 fi
3935
40- # Add formatted output for each line
4136 if [ -n "$line" ]; then
42- output+="${ANSI_CLEAR_LINE}${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
37+ printf "${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
4338 else
44- output+="${ANSI_CLEAR_LINE}${PADDING_LEFT_SPACES}\n"
39+ printf "${PADDING_LEFT_SPACES}\n"
4540 fi
4641 done
4742
48- printf "${ANSI_RESTORE_CURSOR}%b" "$output"
4943 sleep 0.1
5044 done
5145 ) &
@@ -9,43 +9,37 @@ monitor_pid=""
9 start_log_output() {9 start_log_output() {
10 local ANSI_SAVE_CURSOR="\033[s"10 local ANSI_SAVE_CURSOR="\033[s"
11 local ANSI_RESTORE_CURSOR="\033[u"11 local ANSI_RESTORE_CURSOR="\033[u"
12- local ANSI_CLEAR_LINE="\033[2K"12+ local ANSI_CLEAR_BELOW="\033[0J"
13 local ANSI_HIDE_CURSOR="\033[?25l"13 local ANSI_HIDE_CURSOR="\033[?25l"
14 local ANSI_RESET="\033[0m"14 local ANSI_RESET="\033[0m"
15 local ANSI_GRAY="\033[90m"15 local ANSI_GRAY="\033[90m"
16 16
17- # Save cursor position and hide cursor
18 printf $ANSI_SAVE_CURSOR17 printf $ANSI_SAVE_CURSOR
19 printf $ANSI_HIDE_CURSOR18 printf $ANSI_HIDE_CURSOR
20 19
21- # Start background monitor process
22 (20 (
23 local log_lines=2021 local log_lines=20
24 local max_line_width=$((LOGO_WIDTH - 4))22 local max_line_width=$((LOGO_WIDTH - 4))
25 23
26 while true; do24 while true; do
27- # Read the last N lines into an array
28 mapfile -t current_lines < <(tail -n $log_lines "$ARCHUP_INSTALL_LOG_FILE" 2>/dev/null)25 mapfile -t current_lines < <(tail -n $log_lines "$ARCHUP_INSTALL_LOG_FILE" 2>/dev/null)
29 26
30- # Build complete output buffer with escape sequences27+ printf "${ANSI_RESTORE_CURSOR}${ANSI_CLEAR_BELOW}"
31- output=""28+
32 for ((i = 0; i < log_lines; i++)); do29 for ((i = 0; i < log_lines; i++)); do
33 line="${current_lines[i]:-}"30 line="${current_lines[i]:-}"
34 31
35- # Truncate if needed
36 if [ ${#line} -gt $max_line_width ]; then32 if [ ${#line} -gt $max_line_width ]; then
37 line="${line:0:$max_line_width}..."33 line="${line:0:$max_line_width}..."
38 fi34 fi
39 35
40- # Add formatted output for each line
41 if [ -n "$line" ]; then36 if [ -n "$line" ]; then
42- output+="${ANSI_CLEAR_LINE}${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"37+ printf "${ANSI_GRAY}${PADDING_LEFT_SPACES} → ${line}${ANSI_RESET}\n"
43 else38 else
44- output+="${ANSI_CLEAR_LINE}${PADDING_LEFT_SPACES}\n"39+ printf "${PADDING_LEFT_SPACES}\n"
45 fi40 fi
46 done41 done
47 42
48- printf "${ANSI_RESTORE_CURSOR}%b" "$output"
49 sleep 0.143 sleep 0.1
50 done44 done
51 ) &45 ) &

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close