Repository navigation
Expand file tree
/
Copy pathshpool.bashrc
More file actions
459 lines (443 loc) · 20.3 KB
/
Copy pathshpool.bashrc
File metadata and controls
459 lines (443 loc) · 20.3 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# shellcheck shell=bash
# ---- session-kit shpool integration -----------------------------------------
# Source this block from ~/.bashrc. Installed releases keep this file immutable.
export PATH="$HOME/.cargo/bin:$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
# Keep AI TUI output in normal terminal history. The session journal is the
# reconnect source; provider-native transcripts remain the conversation source.
export CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1
__sk_state_root=${XDG_STATE_HOME:-"$HOME/.local/state"}
__sk_journal_root=${SESSION_KIT_JOURNAL_DIR:-"$__sk_state_root/shpool-journal"}
# A disabled journal is still a launch-ready shell. Mark it explicitly so the
# one-shot provider record below is consumed without starting `script`.
if [[ -n ${SHPOOL_SESSION_NAME:-} && -z ${SHPOOL_JOURNAL:-} && $- == *i* \
&& -e $HOME/.no_shpool_journal ]]; then
export SHPOOL_JOURNAL=disabled
fi
# New sessions write one append-only segment for their entire live lifetime.
# Active segments are never replaced or trimmed. Existing legacy sessions keep
# their already-open writer and are handled by the recovery map.
if [[ -n ${SHPOOL_SESSION_NAME:-} && -z ${SHPOOL_JOURNAL:-} && $- == *i* && -t 1 \
&& ! -e $HOME/.no_shpool_journal ]]; then
__sk_session_journal="$__sk_journal_root/$SHPOOL_SESSION_NAME"
__sk_journal_ready=1
mkdir -p "$__sk_session_journal" || __sk_journal_ready=0
if (( __sk_journal_ready )); then
chmod 700 "$__sk_session_journal" || __sk_journal_ready=0
fi
if (( __sk_journal_ready )); then
export SHPOOL_JOURNAL="$__sk_session_journal/segment-000001.raw"
( umask 077; : >> "$SHPOOL_JOURNAL" ) || __sk_journal_ready=0
chmod 600 "$SHPOOL_JOURNAL" || __sk_journal_ready=0
fi
if (( ! __sk_journal_ready )); then
echo "[session-kit: journal unavailable; continuing without capture]" >&2
export SHPOOL_JOURNAL=disabled
exec bash -i
fi
if [[ $(uname -s 2>/dev/null) == Darwin ]]; then
if [[ ${SESSION_KIT_MACOS_PREVIEW:-0} != 1 ]]; then
echo "[session-kit: macOS preview is disabled; continuing without capture]" >&2
export SHPOOL_JOURNAL=disabled
exec bash -i
fi
script -q -F -a "$SHPOOL_JOURNAL" bash -i
else
script -qfa "$SHPOOL_JOURNAL" -c "bash -i"
fi
__sk_script_rc=$?
if (( __sk_script_rc != 0 )); then
echo "[session-kit: journal process failed; continuing without capture]" >&2
export SHPOOL_JOURNAL=disabled
exec bash -i
fi
unset __sk_script_rc __sk_journal_ready
builtin exit
fi
if [[ -n ${SHPOOL_SESSION_NAME:-} && $- == *i* ]]; then
__sk_start_dir=${SESSION_KIT_START_DIR:-"$__sk_state_root/shpool-start"}
__sk_start="$__sk_start_dir/$SHPOOL_SESSION_NAME"
__sk_expected="$__sk_start.expected"
if [[ -n ${SHPOOL_JOURNAL:-} && -r $__sk_start ]]; then
# The shell can start before `sp` has captured its exact generation. Wait
# only for an atomically written sidecar; an unarmed or stale main record
# never launches a provider.
for __sk_arm_attempt in {1..30}; do
[[ -r $__sk_expected ]] && break
sleep 0.1
done
fi
if [[ -n ${SHPOOL_JOURNAL:-} && -r $__sk_start && -r $__sk_expected ]]; then
__sk_provider= __sk_cwd= __sk_uuid= __sk_launch_mode=
__sk_side_provider= __sk_side_cwd= __sk_side_uuid= __sk_side_launch_mode=
__sk_boot_id= __sk_started= __sk_shell_pid= __sk_shell_start=
__sk_daemon_pid= __sk_daemon_start=
__sk_record_shape_ok=0
if python3 - "$__sk_start" "$__sk_expected" <<'PY'
import sys
expected_tabs = ({2, 3}, {8, 9})
for path, allowed in zip(sys.argv[1:], expected_tabs):
with open(path, "rb") as handle:
payload = handle.read(8193)
if (
not payload
or len(payload) > 8192
or not payload.endswith(b"\n")
or payload.count(b"\n") != 1
or b"\r" in payload
or b"\x1c" in payload
or payload[:-1].count(b"\t") not in allowed
):
raise SystemExit(1)
PY
then
IFS= read -r __sk_start_line < "$__sk_start"
IFS= read -r __sk_expected_line < "$__sk_expected"
__sk_start_line=${__sk_start_line//$'\t'/$'\034'}
__sk_expected_line=${__sk_expected_line//$'\t'/$'\034'}
IFS=$'\034' read -r __sk_provider __sk_cwd __sk_uuid __sk_launch_mode <<<"$__sk_start_line"
IFS=$'\034' read -r __sk_side_provider __sk_side_cwd \
__sk_boot_id __sk_started __sk_shell_pid __sk_shell_start \
__sk_daemon_pid __sk_daemon_start __sk_side_uuid __sk_side_launch_mode <<<"$__sk_expected_line"
__sk_record_shape_ok=1
fi
if [[ -z $__sk_launch_mode ]]; then
if [[ -n $__sk_uuid ]]; then __sk_launch_mode=resume; else __sk_launch_mode=new; fi
fi
if [[ -z $__sk_side_launch_mode ]]; then
if [[ -n $__sk_side_uuid ]]; then __sk_side_launch_mode=resume; else __sk_side_launch_mode=new; fi
fi
# Session shells are spawned by the shpool daemon and carry NO kit
# environment, so the release must be derived from this file's own
# location (resolving the `current` link pins the release active at
# session start). The env overrides remain for tests and tooling.
__sk_release_root=${SESSION_KIT_RELEASE_DIR:-}
if [[ -z $__sk_release_root ]]; then
__sk_release_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." 2>/dev/null && pwd -P) ||
__sk_release_root=""
fi
__sk_inventory_core=${SESSION_KIT_INVENTORY_CORE:-$__sk_release_root/lib/session_inventory.py}
unset __sk_release_root
if [[ -n ${SESSION_KIT_BOOT_ID_FILE:-} ]]; then
__sk_current_boot_id=$(command cat -- "$SESSION_KIT_BOOT_ID_FILE" 2>/dev/null || true)
elif [[ $(uname -s 2>/dev/null) == Darwin && ${SESSION_KIT_MACOS_PREVIEW:-0} == 1 &&
-f $__sk_inventory_core ]]; then
__sk_current_boot_id=$(python3 "$__sk_inventory_core" platform boot-id 2>/dev/null || true)
else
__sk_current_boot_id=$(command cat -- /proc/sys/kernel/random/boot_id 2>/dev/null || true)
fi
__sk_current_boot_id=${__sk_current_boot_id//$'\r'/}
__sk_current_boot_id=${__sk_current_boot_id//$'\n'/}
__sk_generation_ok=0
__sk_proc_identity() {
local __sk_pid=$1 __sk_stat __sk_tail
local -a __sk_fields
if [[ $(uname -s 2>/dev/null) == Darwin ]]; then
[[ ${SESSION_KIT_MACOS_PREVIEW:-0} == 1 && -f $__sk_inventory_core ]] ||
return 1
python3 "$__sk_inventory_core" platform process-info "$__sk_pid" 2>/dev/null |
command tr '\t' ' '
return
fi
[[ -r /proc/$__sk_pid/stat ]] || return 1
__sk_stat=$(<"/proc/$__sk_pid/stat") || return 1
__sk_tail=${__sk_stat##*) }
read -r -a __sk_fields <<<"$__sk_tail"
[[ ${#__sk_fields[@]} -ge 20 ]] || return 1
printf '%s %s\n' "${__sk_fields[1]}" "${__sk_fields[19]}"
}
__sk_launch_mode_ok=0
if [[ $__sk_launch_mode == new && -z $__sk_uuid ]]; then
__sk_launch_mode_ok=1
elif [[ ( $__sk_launch_mode == resume || $__sk_launch_mode == fork ) &&
$__sk_provider =~ ^(claude|codex)$ &&
$__sk_uuid =~ ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$ ]]; then
__sk_launch_mode_ok=1
fi
if (( __sk_record_shape_ok && __sk_launch_mode_ok )) &&
[[ $__sk_provider == "$__sk_side_provider" &&
$__sk_cwd == "$__sk_side_cwd" &&
$__sk_uuid == "$__sk_side_uuid" &&
$__sk_launch_mode == "$__sk_side_launch_mode" &&
-n $__sk_boot_id && $__sk_boot_id == "$__sk_current_boot_id" &&
$__sk_started =~ ^[0-9]+$ &&
$__sk_shell_pid =~ ^[0-9]+$ && $__sk_shell_start =~ ^[0-9]+$ &&
$__sk_daemon_pid =~ ^[0-9]+$ && $__sk_daemon_start =~ ^[0-9]+$ ]]; then
__sk_walk_pid=$$
for __sk_walk_depth in {1..6}; do
read -r __sk_walk_ppid __sk_walk_start < <(__sk_proc_identity "$__sk_walk_pid") || break
if [[ $__sk_walk_pid == "$__sk_shell_pid" && $__sk_walk_start == "$__sk_shell_start" ]]; then
read -r __sk_parent_ppid __sk_parent_start < <(__sk_proc_identity "$__sk_walk_ppid") || break
if [[ $__sk_walk_ppid == "$__sk_daemon_pid" && $__sk_parent_start == "$__sk_daemon_start" ]]; then
__sk_generation_ok=1
fi
break
fi
__sk_walk_pid=$__sk_walk_ppid
done
fi
if (( ! __sk_generation_ok )); then
echo "[session-kit: stale or mismatched launch record retained; provider not started]" >&2
elif [[ $__sk_cwd == /* && -d $__sk_cwd ]]; then
if ! cd -- "$__sk_cwd"; then
echo "[session-kit: launch directory is unavailable; launch record retained for retry]" >&2
else
__sk_provider_launched=0
__sk_provider_exited=0
__sk_provider_rc=0
case "$__sk_provider" in
claude)
if ! command -v claude >/dev/null 2>&1; then
echo "[session-kit: Claude is unavailable; launch record retained for retry]" >&2
else
command rm -- "$__sk_start" "$__sk_expected"
__sk_provider_launched=1
case "$__sk_launch_mode" in
new) claude; __sk_provider_rc=$? ;;
resume) claude --resume "$__sk_uuid"; __sk_provider_rc=$? ;;
fork) claude --resume "$__sk_uuid" --fork-session; __sk_provider_rc=$? ;;
esac
fi
;;
codex)
if ! command -v codex >/dev/null 2>&1; then
echo "[session-kit: Codex is unavailable; launch record retained for retry]" >&2
else
# A managed session is launched with nobody watching it. Codex's
# startup upgrade prompt blocks on a keypress that never comes, so
# the session sits at "setup incomplete" forever and its
# conversation never loads. Suppressed explicitly here rather than
# relying on user config.
__sk_codex_no_update=(-c check_for_update_on_startup=false)
# Codex has no per-thread color; the session's kit color rides in
# as a per-launch theme override (status line, thread-title item).
# Resumes and forks color from the conversation's effective color;
# a brand-new session has no conversation ID yet, so it launches
# with a color picked from the shpool session name — the collector
# adopts that pick as the conversation's override once the ID
# exists, keeping window, picker, and future resumes identical.
# Fail-open: unknown color or missing theme file launches plain.
command rm -- "$__sk_start" "$__sk_expected"
__sk_provider_launched=1
# A new-mode Codex boots before any thread title can exist, so its
# status bar shows the conversation ID for that process's life.
# The marker lets the picker request one safe provider bounce
# (codex resume of the same conversation) once a title exists.
if [[ $__sk_launch_mode == new ]]; then
( umask 077
mkdir -p "$__sk_state_root/session-kit/provider-untitled" &&
: > "$__sk_state_root/session-kit/provider-untitled/$SHPOOL_SESSION_NAME"
) 2>/dev/null || true
fi
while :; do
__sk_codex_theme=()
__sk_theme_color=
if [[ -f $__sk_inventory_core ]]; then
if [[ -n $__sk_uuid ]]; then
__sk_theme_color=$(python3 "$__sk_inventory_core" color effective codex "$__sk_uuid" 2>/dev/null || true)
else
__sk_theme_color=$(python3 "$__sk_inventory_core" color launch-pick "$SHPOOL_SESSION_NAME" 2>/dev/null || true)
fi
fi
case "$__sk_theme_color" in
red|blue|green|yellow|purple|orange|pink|cyan)
if [[ -r ${CODEX_HOME:-$HOME/.codex}/themes/sk-$__sk_theme_color.tmTheme ]]; then
__sk_codex_theme=(-c "tui.theme=\"sk-$__sk_theme_color\"")
fi
;;
esac
unset __sk_theme_color
case "$__sk_launch_mode" in
new) codex "${__sk_codex_no_update[@]}" "${__sk_codex_theme[@]}" --no-alt-screen; __sk_provider_rc=$? ;;
resume) codex "${__sk_codex_no_update[@]}" "${__sk_codex_theme[@]}" --no-alt-screen resume "$__sk_uuid"; __sk_provider_rc=$? ;;
fork) codex "${__sk_codex_no_update[@]}" "${__sk_codex_theme[@]}" --no-alt-screen fork "$__sk_uuid"; __sk_provider_rc=$? ;;
esac
# A kit-requested bounce relaunches the SAME conversation once,
# so the fresh process boots with its title and theme. Any other
# exit falls through to the normal provider-exit handling.
__sk_bounce="$__sk_state_root/session-kit/provider-bounce/$SHPOOL_SESSION_NAME"
if [[ -f $__sk_bounce && ! -L $__sk_bounce ]]; then
__sk_bounce_uuid=$(command head -c 64 -- "$__sk_bounce" 2>/dev/null | tr -cd '0-9a-fA-F-')
command rm -f -- "$__sk_bounce"
if [[ $__sk_bounce_uuid =~ ^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$ ]]; then
__sk_uuid=$__sk_bounce_uuid
__sk_launch_mode=resume
unset __sk_bounce_uuid __sk_bounce
continue
fi
unset __sk_bounce_uuid
fi
unset __sk_bounce
break
done
fi
;;
shell)
command rm -- "$__sk_start" "$__sk_expected"
;;
esac
if (( __sk_provider_launched )); then
__sk_lifecycle_core=$__sk_inventory_core
__sk_lifecycle_session=$SHPOOL_SESSION_NAME
__sk_lifecycle_boot=$__sk_current_boot_id
__sk_lifecycle_shell_pid=$__sk_shell_pid
__sk_lifecycle_shell_start=$__sk_shell_start
__sk_lifecycle_provider=$__sk_provider
if SESSION_KIT_LIFECYCLE_SESSION_ID=$__sk_lifecycle_session \
SESSION_KIT_LIFECYCLE_BOOT_ID=$__sk_lifecycle_boot \
SESSION_KIT_LIFECYCLE_SHELL_PID=$__sk_lifecycle_shell_pid \
SESSION_KIT_LIFECYCLE_SHELL_START_TICKS=$__sk_lifecycle_shell_start \
SESSION_KIT_LIFECYCLE_PROVIDER=$__sk_lifecycle_provider \
SESSION_KIT_LIFECYCLE_EXIT_CODE=$__sk_provider_rc \
python3 "$__sk_lifecycle_core" lifecycle provider-exited >/dev/null
then
__sk_provider_exited=1
printf '\n%s exited with status %s. This terminal is still open.\n' \
"${__sk_provider^}" "$__sk_provider_rc"
else
echo "[session-kit: provider exited; lifecycle proof is unavailable, so automatic cleanup is blocked]" >&2
fi
fi
fi
else
echo "[session-kit: launch record has an unavailable directory; retained for retry]" >&2
fi
fi
unset -f __sk_proc_identity
unset __sk_start_dir __sk_start __sk_expected __sk_arm_attempt
unset __sk_start_line __sk_expected_line __sk_record_shape_ok
unset __sk_provider __sk_cwd __sk_uuid __sk_launch_mode
unset __sk_side_provider __sk_side_cwd __sk_side_uuid __sk_side_launch_mode
unset __sk_boot_id __sk_current_boot_id __sk_inventory_core __sk_started __sk_shell_pid __sk_shell_start __sk_daemon_pid __sk_daemon_start
unset __sk_generation_ok __sk_launch_mode_ok __sk_walk_pid __sk_walk_depth __sk_walk_ppid __sk_walk_start
unset __sk_parent_ppid __sk_parent_start
unset __sk_provider_launched __sk_provider_rc
__sk_lifecycle_event() {
local __sk_lifecycle_action=$1
shift
[[ -n ${__sk_lifecycle_core:-} && -f $__sk_lifecycle_core ]] || return 1
if [[ $__sk_lifecycle_action == reopen ]]; then
SESSION_KIT_LIFECYCLE_SESSION_ID=$__sk_lifecycle_session \
SESSION_KIT_LIFECYCLE_BOOT_ID=$__sk_lifecycle_boot \
SESSION_KIT_LIFECYCLE_SHELL_PID=$__sk_lifecycle_shell_pid \
SESSION_KIT_LIFECYCLE_SHELL_START_TICKS=$__sk_lifecycle_shell_start \
python3 "$__sk_lifecycle_core" lifecycle "$__sk_lifecycle_action" "$@"
else
SESSION_KIT_LIFECYCLE_SESSION_ID=$__sk_lifecycle_session \
SESSION_KIT_LIFECYCLE_BOOT_ID=$__sk_lifecycle_boot \
SESSION_KIT_LIFECYCLE_SHELL_PID=$__sk_lifecycle_shell_pid \
SESSION_KIT_LIFECYCLE_SHELL_START_TICKS=$__sk_lifecycle_shell_start \
python3 "$__sk_lifecycle_core" lifecycle "$__sk_lifecycle_action" "$@" \
>/dev/null
fi
}
keep_session() {
if __sk_lifecycle_event keep on; then
echo "Automatic cleanup is disabled for this terminal."
else
echo "Could not mark this terminal to keep." >&2
return 1
fi
}
unkeep_session() {
if __sk_lifecycle_event keep off; then
echo "Automatic cleanup may resume after every safety condition is met."
else
echo "Could not remove the keep marker." >&2
return 1
fi
}
# `bye` is the convenient confirmed close. A directly typed Bash `exit`
# retains normal shell semantics, as approved.
bye() {
local __sk_answer
printf '\nClose shpool session %s?\n' "$SHPOOL_SESSION_NAME"
read -r -p "Type the exact ID '$SHPOOL_SESSION_NAME' to confirm: " __sk_answer
if [[ $__sk_answer == "$SHPOOL_SESSION_NAME" ]]; then
builtin exit
fi
echo "Close cancelled."
}
__sk_provider_exit_menu() {
local __sk_menu_choice
while true; do
printf '\nProvider exited: [r] reopen conversation [k] keep terminal [s] shell [c] close\n'
if ! IFS= read -r -p "Choice: " __sk_menu_choice; then
# EOF or a terminal signal is user activity. Closing is safe even when
# the private input marker cannot be written.
__sk_lifecycle_event user-input >/dev/null 2>&1 || true
builtin exit
fi
__sk_menu_choice=${__sk_menu_choice,,}
if [[ $__sk_menu_choice == c || $__sk_menu_choice == close ]]; then
__sk_lifecycle_event user-input >/dev/null 2>&1 || true
builtin exit
fi
if ! __sk_lifecycle_event user-input >/dev/null 2>&1; then
echo "Choice not applied: Session Kit could not record terminal use. Close remains available." >&2
continue
fi
case "$__sk_menu_choice" in
r|reopen)
if ! __sk_lifecycle_event reopen; then
echo "Exact recovery is not ready. Choose shell to use the provider directly, or close and reopen from the dashboard." >&2
fi
;;
k|keep)
keep_session
;;
s|shell)
echo "Shell opened. This terminal is permanently excluded from automatic cleanup."
return 0
;;
*)
echo "Unknown choice. Use r, k, s, or c."
;;
esac
done
}
if [[ ${__sk_provider_exited:-0} == 1 ]]; then
__sk_provider_exit_menu
fi
unset __sk_provider_exited
# Local, scoped Needs-you marker. The renderer caches safely and never sends
# an external notification.
__sk_waiting() {
local __sk_prompt_state_root=${XDG_STATE_HOME:-"$HOME/.local/state"}
local __sk_cache="$__sk_prompt_state_root/session-kit/waiting-count"
local __sk_now __sk_mtime __sk_age __sk_count
__sk_now=$(date +%s)
__sk_mtime=$(stat -c %Y "$__sk_cache" 2>/dev/null || stat -f %m "$__sk_cache" 2>/dev/null || echo 0)
__sk_age=$((__sk_now - __sk_mtime))
if (( __sk_age > 20 )); then
(
umask 077
mkdir -p "$(dirname "$__sk_cache")"
"$HOME/.local/bin/shpool_status" --waiting-count > "$__sk_cache" 2>/dev/null
) &
fi
if [[ -r $__sk_cache ]]; then
__sk_count=$(command cat -- "$__sk_cache")
else
__sk_count=0
fi
__sk_count=${__sk_count//[^0-9]/}
if (( ${__sk_count:-0} > 0 )); then
printf '\001\e[33m\002●%s\001\e[0m\002 ' "$__sk_count"
fi
}
PS1="\[\e[38;5;71m\]▌\[\e[0m\] \$(__sk_waiting)$PS1"
fi
unset __sk_state_root __sk_journal_root __sk_session_journal __sk_journal_ready __sk_script_rc
# Auto-open the read-only picker only for interactive SSH terminals.
# Escape hatch: touch ~/.no_shpool.
if [[ $- == *i* && -n ${SSH_CONNECTION:-} && -z ${SHPOOL_SESSION_NAME:-} && -t 0 \
&& ! -e $HOME/.no_shpool && -x $HOME/.local/bin/shpool_login ]]; then
"$HOME/.local/bin/shpool_login"
__sk_rc=$?
if [[ $__sk_rc -eq 0 ]]; then builtin exit; fi
if [[ $__sk_rc -ne 2 ]]; then
echo "[session picker unavailable; continuing in a plain shell]"
fi
unset __sk_rc
fi
# ---- end session-kit shpool integration -------------------------------------