-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·94 lines (82 loc) · 3.33 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·94 lines (82 loc) · 3.33 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
#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# sandy installer
#
# Usage: curl -fsSL https://raw.githubusercontent.com/rappdw/sandy/main/install.sh | bash
# =============================================================================
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
SANDY_URL="${SANDY_URL:-https://raw.githubusercontent.com/rappdw/sandy/main/sandy}"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
info() { echo -e "${GREEN}[sandy]${NC} $*"; }
warn() { echo -e "${YELLOW}[sandy]${NC} $*"; }
error() { echo -e "${RED}[sandy]${NC} $*" >&2; }
# --- Check prerequisites ---
if ! command -v docker &>/dev/null; then
warn "Docker is not installed. sandy requires Docker to run."
warn " Install: https://docs.docker.com/get-docker/"
fi
if ! command -v node &>/dev/null; then
warn "Node.js is not installed. sandy uses Node.js for JSON config merging (optional)."
warn " Install: https://nodejs.org/"
fi
if ! command -v gh &>/dev/null; then
warn "GitHub CLI (gh) is not installed. Required for default git auth (SANDY_SSH=token)."
warn " Install: https://cli.github.com"
warn " Then run: gh auth login"
elif ! gh auth token &>/dev/null; then
warn "GitHub CLI is installed but not authenticated. Run: gh auth login"
fi
# --- Create install dir if needed ---
mkdir -p "$INSTALL_DIR"
# --- Download or copy sandy ---
if [ -n "${LOCAL_INSTALL:-}" ] && [ -f "$LOCAL_INSTALL" ]; then
info "Installing sandy from local file: $LOCAL_INSTALL"
cp "$LOCAL_INSTALL" "$INSTALL_DIR/sandy"
# Bake in git commit hash if installing from a repo checkout
local_dir="$(cd "$(dirname "$LOCAL_INSTALL")" && pwd)"
commit_hash="$(git -C "$local_dir" rev-parse --short HEAD 2>/dev/null)" || true
if [ -n "$commit_hash" ]; then
# BSD sed (macOS) requires -i '', GNU sed (Linux) requires -i without arg
if sed --version 2>/dev/null | grep -q GNU; then
sed -i "s/^SANDY_COMMIT=\"\"/SANDY_COMMIT=\"$commit_hash\"/" "$INSTALL_DIR/sandy"
else
sed -i '' "s/^SANDY_COMMIT=\"\"/SANDY_COMMIT=\"$commit_hash\"/" "$INSTALL_DIR/sandy"
fi
fi
else
info "Downloading sandy..."
if command -v curl &>/dev/null; then
curl -fsSL "$SANDY_URL" -o "$INSTALL_DIR/sandy"
elif command -v wget &>/dev/null; then
wget -qO "$INSTALL_DIR/sandy" "$SANDY_URL"
else
error "Neither curl nor wget found. Cannot download sandy."
exit 1
fi
fi
chmod +x "$INSTALL_DIR/sandy"
info "Installed sandy to $INSTALL_DIR/sandy"
# --- Check PATH ---
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$INSTALL_DIR"; then
warn ""
warn "$INSTALL_DIR is not in your PATH. Add it with:"
warn ""
SHELL_NAME="$(basename "${SHELL:-/bin/bash}")"
case "$SHELL_NAME" in
zsh) warn " echo 'export PATH=\"$INSTALL_DIR:\$PATH\"' >> ~/.zshrc && source ~/.zshrc" ;;
bash) warn " echo 'export PATH=\"$INSTALL_DIR:\$PATH\"' >> ~/.bashrc && source ~/.bashrc" ;;
fish) warn " fish_add_path $INSTALL_DIR" ;;
*) warn " export PATH=\"$INSTALL_DIR:\$PATH\"" ;;
esac
warn ""
fi
echo ""
info "Done! Run 'sandy' from any project directory to start Claude in a sandbox."
info ""
info " cd ~/my-project"
info " sandy"
info " sandy -p \"your prompt here\""