← back to Terminal Status
verification/install/before/.claude/skills/dot/current.sh
26 lines
#!/usr/bin/env bash
# /dot helper — print THIS session's controlling tty + its current persisted dot label,
# so the /dot review can report "was: <X>" and avoid a no-op re-apply.
# Resolves the tty the same way the dot scripts do (walk process ancestry to the ttysNNN),
# because the Claude Bash tool has no controlling tty of its own.
set -u
tty_path=""; p=$$
for _ in 1 2 3 4 5 6 7 8 9 10; do
line="$(ps -o ppid=,tty= -p "$p" 2>/dev/null)" || break
set -- $line
pp="${1:-}"; tt="${2:-}"
[[ -z "$pp" ]] && break
if [[ "$tt" == ttys* ]]; then tty_path="/dev/$tt"; break; fi
p="$pp"
done
if [[ -z "$tty_path" ]]; then
echo "(none) — could not resolve this session's tty"; exit 0
fi
base="$(basename "$tty_path")"
dotfile="${HOME}/.claude/tab-dots/${base}.dot"
if [[ -f "$dotfile" ]]; then
printf '%s %s\n' "$base" "$(cat "$dotfile")"
else
printf '%s (none)\n' "$base"
fi