left.sh RawHistoryFolder

1#!/bin/bash
2# Left: the active workspace as an accent block that fades into the bar, then
3# the workspaces with one dot per window. The active workspace shows only its
4# dots. On NeferWL it also shows the stash. Without NeferWL's state file it
5# shows nothing.
6. "$(dirname "$0")/lib.sh"
7
8DOT=$ICON_DOT STASH=$ICON_STASH
9[ -r "${NEFERWL_STATE:-}" ] || {
10	echo
11	exec sleep infinity
12}
13
14draw() {
15	# First line: "<active> <count>" of the focused output. Then one line per
16	# workspace: "<n> <windows> <stashed>".
17	local data active count n w s line pips
18	data=$(jq -r '
19		.output as $o
20		| (.outputs[] | select(.name == $o)) as $out
21		| [.windows[] | select(.output == $o)] as $ws
22		| "\($out.active) \($out.count)",
23		  (range(1; $out.count + 1) as $n
24		   | [$ws[] | select(.workspace == $n)] as $here
25		   | "\($n) \($here | length) \([$here[] | select(.stash_count > 0)] | length)")' \
26		"$NEFERWL_STATE" 2>/dev/null) || return
27	read -r active count <<<"$(head -1 <<<"$data")"
28	# The state file is data, not code: bash arithmetic runs command
29	# substitutions, so only digits may reach it.
30	[[ $active =~ ^[0-9]+$ && $count =~ ^[0-9]+$ ]] || return
31
32	line="$(bg "$ACCENT")$(fg "$(ink "$ACCENT")")$BOLD  $active $RESET$(fade "$ACCENT" "$BAR")$(bg "$BAR")"
33	while read -r n w s; do
34		[[ $n =~ ^[0-9]+$ && $w =~ ^[0-9]+$ && $s =~ ^[0-9]+$ ]] || continue
35		# One dot per window, at most 4.
36		pips=""
37		((w > 0)) && printf -v pips "$DOT%.0s" $(seq 1 $((w > 4 ? 4 : w)))
38		if ((n == active)); then
39			# The number is already in the accent block on the left.
40			line+="$(fg "$NEFERBAR_FOREGROUND") $pips"
41			((s > 0)) && line+="$(fg "$NEFERBAR_COLOR2") $STASH$s"
42			line+=" "
43		elif ((w > 0)); then
44			line+="$(fg "$NEFERBAR_FOREGROUND") $n $(fg "$DIM")$pips "
45		else
46			line+="$(fg "$DIM") $n "
47		fi
48	done < <(tail -n +2 <<<"$data")
49	printf '%s%s\f' "$line" "$RESET"
50}
51
52state_changed_loop draw

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 5

Tags 4

↑↓ moveenter openesc close