-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·61 lines (52 loc) · 1.8 KB
/
install.sh
File metadata and controls
executable file
·61 lines (52 loc) · 1.8 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
#!/usr/bin/env bash
# git-chord installer
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEFAULT_INSTALL_DIR="$HOME/.git-chord"
INSTALL_DIR="${GIT_CHORD_DIR:-$DEFAULT_INSTALL_DIR}"
REPO_URL="${GIT_CHORD_REPO_URL:-git@github.com:socket-link/git-chord.git}"
# Prefer local repo if we're running inside it and no explicit install dir is set
LOCAL_REPO_DIR=""
if git -C "$SCRIPT_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
REPO_TOPLEVEL="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel)"
if [ -f "$REPO_TOPLEVEL/git-chord.zsh" ]; then
LOCAL_REPO_DIR="$REPO_TOPLEVEL"
fi
fi
if [ -z "${GIT_CHORD_DIR:-}" ] && [ -n "$LOCAL_REPO_DIR" ]; then
INSTALL_DIR="$LOCAL_REPO_DIR"
fi
echo "Installing git-chord to $INSTALL_DIR..."
# Clone or update (unless using local repo)
if [ "$INSTALL_DIR" = "$LOCAL_REPO_DIR" ] && [ -n "$LOCAL_REPO_DIR" ]; then
echo "Using local repo at $INSTALL_DIR"
elif [ -d "$INSTALL_DIR" ]; then
echo "Updating existing installation..."
cd "$INSTALL_DIR" && git pull
else
git clone "$REPO_URL" "$INSTALL_DIR"
fi
# Detect shell config
if [ -f "$HOME/.zshrc" ]; then
SHELL_RC="$HOME/.zshrc"
elif [ -f "$HOME/.zprofile" ]; then
SHELL_RC="$HOME/.zprofile"
else
echo "Could not find .zshrc or .zprofile"
echo "Add this line manually to your shell config:"
echo " source $INSTALL_DIR/git-chord.zsh"
exit 0
fi
# Add source line if not present
SOURCE_LINE="source $INSTALL_DIR/git-chord.zsh"
if ! grep -qF "git-chord.zsh" "$SHELL_RC"; then
echo "" >> "$SHELL_RC"
echo "# git-chord - vim-style composable git commands" >> "$SHELL_RC"
echo "$SOURCE_LINE" >> "$SHELL_RC"
echo "Added to $SHELL_RC"
else
echo "Already in $SHELL_RC"
fi
echo ""
echo "✓ Installed! Run 'source $SHELL_RC' or open a new terminal."
echo " Type 'ghelp' to see available commands."