claude-launcher-profiles/bin/install-claude-profiles
dschlueter 35b2da39d2 fix: harden installer symlink logic and interactive sourcing
- install-claude-profiles: distinguish broken symlink vs real dir vs free
  path via -L/-e, repoint existing links with ln -sfn, warn instead of
  silently skipping when target is a non-symlink dir.
- profiles.sh: only set -euo pipefail when sourced non-interactively so
  sourcing in an interactive shell doesn't clobber session settings.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-28 03:23:03 +02:00

31 lines
850 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
TARGET_DIR="$HOME/src"
TARGET_REPO="$TARGET_DIR/claude-launcher-profiles"
BASHRC="$HOME/.bashrc"
ALIAS_LINE="source $TARGET_REPO/shell/aliases.sh"
mkdir -p "$TARGET_DIR"
if [[ "$REPO_DIR" != "$TARGET_REPO" ]]; then
if [[ -L "$TARGET_REPO" ]]; then
ln -sfn "$REPO_DIR" "$TARGET_REPO"
elif [[ -e "$TARGET_REPO" ]]; then
echo "Warning: $TARGET_REPO exists and is not a symlink;" >&2
echo " aliases will point there. Remove it to repoint to $REPO_DIR." >&2
else
ln -s "$REPO_DIR" "$TARGET_REPO"
fi
fi
touch "$BASHRC"
if ! grep -Fq "$ALIAS_LINE" "$BASHRC"; then
printf '\n# claude-launcher-profiles\n%s\n' "$ALIAS_LINE" >> "$BASHRC"
fi
echo "Installed. Run: source ~/.bashrc"