-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·106 lines (90 loc) · 2.65 KB
/
install.sh
File metadata and controls
executable file
·106 lines (90 loc) · 2.65 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
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
# broom installer script
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}🧹 Installing broom - Git Branch Housekeeping Tool${NC}"
echo ""
# Detect platform
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS-$ARCH" in
Darwin-arm64) FILE="broom-macos-arm64" ;;
Darwin-x86_64) FILE="broom-macos-x64" ;;
Linux-x86_64) FILE="broom-linux-x64" ;;
*)
echo -e "${RED}❌ Unsupported platform: $OS-$ARCH${NC}"
echo "Supported platforms:"
echo " - macOS (arm64, x86_64)"
echo " - Linux (x86_64)"
exit 1
;;
esac
# Get latest version or use specified version
VERSION="${1:-latest}"
if [ "$VERSION" = "latest" ]; then
echo -e "${BLUE}📡 Fetching latest version...${NC}"
VERSION=$(curl -fsSL https://api.github.com/repos/ggalmazor/broom/releases/latest | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo -e "${RED}❌ Failed to fetch latest version${NC}"
exit 1
fi
echo -e "${GREEN}✓ Latest version: v$VERSION${NC}"
VERSION="v$VERSION"
else
# Ensure version starts with 'v'
if [[ ! "$VERSION" =~ ^v ]]; then
VERSION="v$VERSION"
fi
fi
URL="https://github.com/ggalmazor/broom/releases/download/$VERSION/$FILE"
echo -e "${BLUE}📦 Downloading broom $VERSION for $OS-$ARCH...${NC}"
# Download to temp location
TEMP_FILE="/tmp/broom-$$"
if ! curl -fsSL "$URL" -o "$TEMP_FILE"; then
echo -e "${RED}❌ Failed to download broom${NC}"
echo "URL: $URL"
exit 1
fi
chmod +x "$TEMP_FILE"
# Determine install location
if [ -d "$HOME/bin" ]; then
INSTALL_DIR="$HOME/bin"
elif [ -w /usr/local/bin ]; then
INSTALL_DIR="/usr/local/bin"
else
INSTALL_DIR="$HOME/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
INSTALL_PATH="$INSTALL_DIR/broom"
# Move to install location
mv "$TEMP_FILE" "$INSTALL_PATH"
echo -e "${GREEN}✓ Installed to $INSTALL_PATH${NC}"
echo ""
# Check if in PATH
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
echo -e "${YELLOW}⚠️ $INSTALL_DIR is not in your PATH${NC}"
echo "Add this to your shell profile (~/.zshrc, ~/.bashrc, etc.):"
echo -e " ${BLUE}export PATH=\"$INSTALL_DIR:\$PATH\"${NC}"
echo ""
fi
# Test installation
if command -v broom >/dev/null 2>&1; then
echo -e "${GREEN}🎉 Installation complete!${NC}"
echo ""
broom --version
echo ""
echo "Try it out:"
echo " broom --help"
echo " broom sweep --dry-run"
else
echo -e "${YELLOW}⚠️ Installation complete, but broom is not in PATH${NC}"
echo "You may need to:"
echo " 1. Add $INSTALL_DIR to your PATH"
echo " 2. Restart your terminal"
echo " 3. Run: export PATH=\"$INSTALL_DIR:\$PATH\""
fi