-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession-controls
More file actions
executable file
·52 lines (47 loc) · 2.37 KB
/
session-controls
File metadata and controls
executable file
·52 lines (47 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# session-controls — TUI action menu for managing the current feature session
# Auto-launched by new-feature in the bottom pane of the cmux workspace.
set -e
# ── Dependency check ─────────────────────────────────────────────────────────
if ! command -v gum &>/dev/null; then
echo "Error: 'gum' is not installed."
echo "Install it with: brew install gum"
exit 1
fi
# ── Banner (rendered once, before the loop) ───────────────────────────────────
tput clear
gum style \
--border rounded \
--border-foreground 6 \
--align center \
--padding "0 2" \
"SESSION CONTROLS"
# ── Action loop ───────────────────────────────────────────────────────────────
# To add a new action: add it to the gum choose list AND add a matching case branch.
# IMPORTANT: always wrap gum confirm in an `if` — under set -e, a non-zero exit
# (user pressed No/Escape) would otherwise kill the script instead of looping back.
# Post-action policy: workspace-closing actions call break/exit; all others loop back.
#
# Future actions to add here: "Create PR", "Push & Merge", "Abandon"
while true; do
ACTION=$(gum choose \
"End Session" \
) || true
[[ -z "$ACTION" ]] && exit 0 # Escape/q/Ctrl-Z exits the TUI
case "$ACTION" in
"End Session")
if gum confirm --selected.foreground="1" "End this session?"; then # red "Yes" button
done-feature
# done-feature calls cmux close-workspace, which terminates this shell.
# The break below is unreachable but documents intent for readers.
break
fi
;;
# ── Future action handlers go here ───────────────────────────────────────
# "Create PR")
# ...do the work...
# # Non-workspace-closing: fall through to loop back to gum choose
# ;;
# ─────────────────────────────────────────────────────────────────────────
esac
done