-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·74 lines (63 loc) · 2.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·74 lines (63 loc) · 2.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
#!/bin/bash
# Vole installer — Linux and macOS.
# Usage: ./install.sh (from a clone)
# curl -fsSL https://raw.githubusercontent.com/<owner>/vole/main/install.sh | bash
set -euo pipefail
REPO_URL="${VOLE_REPO_URL:-https://github.com/fschrhunt/vole}"
INSTALL_DIR="${VOLE_INSTALL_DIR:-$HOME/.vole}"
say() { printf '%s\n' "$*"; }
die() {
printf 'Error: %s\n' "$*" >&2
exit 1
}
command -v git > /dev/null 2>&1 || die "git is required"
# When run from inside a clone, install from it; otherwise clone fresh.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-.}")" 2> /dev/null && pwd || echo "")"
if [[ -n "$SCRIPT_DIR" && -f "$SCRIPT_DIR/vole" && -d "$SCRIPT_DIR/lib" ]]; then
INSTALL_DIR="$SCRIPT_DIR"
say "Installing from local checkout: $INSTALL_DIR"
elif [[ -d "$INSTALL_DIR/.git" ]]; then
say "Updating existing install in $INSTALL_DIR"
git -C "$INSTALL_DIR" pull --ff-only
else
say "Cloning Vole into $INSTALL_DIR"
git clone --depth 1 "$REPO_URL" "$INSTALL_DIR"
fi
chmod +x "$INSTALL_DIR/vole" "$INSTALL_DIR"/bin/*.sh
# Pick a bin directory that is (or can be) on PATH.
BIN_DIR=""
for candidate in "$HOME/.local/bin" /opt/homebrew/bin /usr/local/bin; do
if [[ -d "$candidate" && -w "$candidate" ]]; then
BIN_DIR="$candidate"
break
fi
done
if [[ -z "$BIN_DIR" ]]; then
BIN_DIR="$HOME/.local/bin"
mkdir -p "$BIN_DIR"
fi
ln -sf "$INSTALL_DIR/vole" "$BIN_DIR/vole"
ln -sf "$INSTALL_DIR/vole" "$BIN_DIR/vo"
say "Linked: $BIN_DIR/vole and $BIN_DIR/vo"
case ":$PATH:" in
*":$BIN_DIR:"*) ;;
*)
if [[ "$(uname -s)" == "Darwin" && "$BIN_DIR" == "$HOME/.local/bin" ]]; then
# macOS zsh does not include ~/.local/bin by default; wire it up.
PROFILE="$HOME/.zprofile"
LINE='export PATH="$HOME/.local/bin:$PATH"'
if ! grep -qsF "$LINE" "$PROFILE" 2> /dev/null; then
printf '\n# Added by Vole installer\n%s\n' "$LINE" >> "$PROFILE"
say "Added $BIN_DIR to PATH in $PROFILE (takes effect in new shells)"
fi
else
say ""
say "Note: $BIN_DIR is not on your PATH. Add this to your shell profile:"
say " export PATH=\"$BIN_DIR:\$PATH\""
fi
;;
esac
say ""
"$BIN_DIR/vole" version
say ""
say "Done. Run 'vo' to start."