2026-04-25 22:13:25 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
# install.sh — symlink session-tools/bin/* into ~/bin (idempotent).
|
|
|
|
|
#
|
|
|
|
|
# Run this on every host that should have remote-run / tssh available.
|
|
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
repo_dir=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
|
|
2026-04-25 22:14:08 -07:00
|
|
|
# Pick the first install target that's already on $PATH so the symlinks are
|
|
|
|
|
# immediately usable. Override with TARGET=<dir> ./install.sh.
|
|
|
|
|
pick_target() {
|
|
|
|
|
if [ -n "${TARGET:-}" ]; then
|
|
|
|
|
printf %s "$TARGET"
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
for candidate in "$HOME/bin" "$HOME/.local/bin"; do
|
|
|
|
|
case ":$PATH:" in
|
|
|
|
|
*":$candidate:"*) printf %s "$candidate"; return ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
# Nothing on PATH — fall back to ~/bin and warn later.
|
|
|
|
|
printf %s "$HOME/bin"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target=$(pick_target)
|
2026-04-25 22:13:25 -07:00
|
|
|
mkdir -p "$target"
|
|
|
|
|
|
|
|
|
|
for src in "$repo_dir"/bin/*; do
|
|
|
|
|
name=$(basename "$src")
|
|
|
|
|
link="$target/$name"
|
|
|
|
|
if [ -L "$link" ] && [ "$(readlink "$link")" = "$src" ]; then
|
|
|
|
|
echo "ok: $link -> $src"
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
if [ -e "$link" ] && [ ! -L "$link" ]; then
|
|
|
|
|
echo "skip: $link exists and is not a symlink — leaving alone" >&2
|
|
|
|
|
continue
|
|
|
|
|
fi
|
|
|
|
|
ln -sfn "$src" "$link"
|
|
|
|
|
echo "link: $link -> $src"
|
|
|
|
|
done
|
|
|
|
|
|
2026-04-29 13:27:26 -04:00
|
|
|
# Install tmux.conf if tmux is present and the user has no existing config.
|
|
|
|
|
if command -v tmux >/dev/null 2>&1; then
|
|
|
|
|
tmux_conf="$HOME/.tmux.conf"
|
|
|
|
|
if [ ! -f "$tmux_conf" ]; then
|
|
|
|
|
cp "$repo_dir/tmux.conf" "$tmux_conf"
|
|
|
|
|
echo "link: $tmux_conf (installed from repo)"
|
|
|
|
|
tmux source "$tmux_conf" 2>/dev/null && echo "ok: tmux config reloaded" || true
|
|
|
|
|
else
|
|
|
|
|
echo "ok: $tmux_conf already exists — not overwriting"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2026-04-25 22:13:25 -07:00
|
|
|
case ":$PATH:" in
|
|
|
|
|
*":$target:"*) ;;
|
|
|
|
|
*) echo "note: add $target to PATH if it isn't already" ;;
|
|
|
|
|
esac
|