main 7a3b92c

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, in layout order (left to right). The
4# active workspace shows only its dots, and the focused window's dot is in the
5# accent color. On NeferWL it also shows the stash. Without NeferWL's state file
6# it shows nothing.
7. "$(dirname "$0")/lib.sh"
8
9DOT=$ICON_DOT STASH=$ICON_STASH
10[ -r "${NEFERWL_STATE:-}" ] || {
11	echo
12	exec sleep infinity
13}
14
15draw() {
16	# First line: "<active> <count>" of the focused output. Then one line per
17	# workspace: "<n> <windows> <stashed> <focused>", where <focused> is the
18	# place (from 1) of the focused window in the workspace's layout order, or 0.
19	# Windows are ordered by column, then row; floating ones (column 0) come last.
20	local data active count n w s f line pips i color
21	data=$(jq -r '
22		.output as $o
23		| (.outputs[] | select(.name == $o)) as $out
24		| [.windows[] | select(.output == $o)] as $ws
25		| (if .window.output == $o then .window.id else null end) as $focus
26		| "\($out.active) \($out.count)",
27		  (range(1; $out.count + 1) as $n
28		   | [$ws[] | select(.workspace == $n)]
29		   | sort_by([(if (.column // 0) > 0 then .column else 1000000 end), (.row // 0), .id]) as $here
30		   | (if $focus == null then null else ($here | map(.id) | index($focus)) end) as $at
31		   | "\($n) \($here | length) \([$here[] | select(.stash_count > 0)] | length) \(if $at == null then 0 else $at + 1 end)")' \
32		"$NEFERWL_STATE" 2>/dev/null) || return
33	read -r active count <<<"$(head -1 <<<"$data")"
34	# The state file is data, not code: bash arithmetic runs command
35	# substitutions, so only digits may reach it.
36	[[ $active =~ ^[0-9]+$ && $count =~ ^[0-9]+$ ]] || return
37
38	line="$(bg "$ACCENT")$(fg "$(ink "$ACCENT")")$BOLD $active $RESET$(fade "$ACCENT" "$BAR")$(bg "$BAR")"
39	while read -r n w s f; do
40		[[ $n =~ ^[0-9]+$ && $w =~ ^[0-9]+$ && $s =~ ^[0-9]+$ && $f =~ ^[0-9]+$ ]] || continue
41		# One dot per window, at most 4; a focused window past the 4th lights the 4th.
42		pips=""
43		for ((i = 1; i <= (w > 4 ? 4 : w); i++)); do
44			color=$DIM
45			((n == active)) && color=$NEFERBAR_FOREGROUND
46			((i == (f > 4 ? 4 : f))) && color=$ACCENT
47			pips+="$(fg "$color")$DOT"
48		done
49		if ((n == active)); then
50			# The number is already in the accent block on the left.
51			line+=" $pips"
52			((s > 0)) && line+="$(fg "$NEFERBAR_COLOR2") $STASH$s"
53			line+=" "
54		elif ((w > 0)); then
55			line+="$(fg "$NEFERBAR_FOREGROUND") $n $pips "
56		else
57			line+="$(fg "$DIM") $n "
58		fi
59	done < <(tail -n +2 <<<"$data")
60	printf '%s%s\f' "$line" "$RESET"
61}
62
63state_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