-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·53 lines (39 loc) · 1.35 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·53 lines (39 loc) · 1.35 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
#!/usr/bin/zsh
set -e
WORKDIR="$(pwd)"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH_ID="x86_64-musl" ;;
aarch64) ARCH_ID="aarch64-linux" ;;
*) echo "Unsupported architecture: $ARCH" && exit 1 ;;
esac
TOOLS_DIR="$HOME/.tools"
mkdir -p "$TOOLS_DIR"
cd "$TOOLS_DIR"
# Fetch latest version from GitHub
LATEST_VERSION=$(curl -s https://api.github.com/repos/donhk/rushstr/releases/latest | grep tag_name | cut -d '"' -f 4)
if [[ -z "$LATEST_VERSION" ]]; then
echo "❌ Could not determine the latest version" && exit 1
fi
BASE_NAME="rushstr-${LATEST_VERSION}-${ARCH_ID}"
FILENAME="${BASE_NAME}.tar.xz"
URL="https://github.com/donhk/rushstr/releases/download/${LATEST_VERSION}/${FILENAME}"
echo "⬇️ Downloading $FILENAME..."
curl -LO "$URL"
pushd $TOOLS_DIR
echo "📦 Extracting...$TOOLS_DIR/$FILENAME"
tar -xf "$FILENAME"
mv "$TOOLS_DIR/$BASE_NAME/rushstr" "$TOOLS_DIR"
rm -rf "$BASE_NAME" # remove dir
rm -rf "$FILENAME" # remove tar.xz file
# Add to PATH (permanent via ~/.zshrc)
if ! grep -q "$TOOLS_DIR" ~/.zshrc; then
echo "\n# Add rushstr to PATH" >> ~/.zshrc
echo "export PATH=\"$TOOLS_DIR:\$PATH\"" >> ~/.zshrc
echo "🔧 Added rushstr to ~/.zshrc"
fi
popd
# Generate shell integration
"$TOOLS_DIR/rushstr" --zsh-shell-conf
echo "✅ rushstr installed!"
echo "ℹ️ Run 'source ~/.zshrc' to activate rushstr keybinding in this terminal."