-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·81 lines (69 loc) · 2.74 KB
/
install.sh
File metadata and controls
executable file
·81 lines (69 loc) · 2.74 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
#!/bin/bash
# Rax CLI Installation Script
# This script installs rax to your system and optionally adds shell aliases
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="$HOME/.local/bin"
RAX_BINARY="$SCRIPT_DIR/target/release/rax"
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ 🚀 Rax CLI Installer ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
# Check if binary exists
if [ ! -f "$RAX_BINARY" ]; then
echo "❌ Building release binary first..."
cd "$SCRIPT_DIR" && cargo build --release
fi
# Create install directory
mkdir -p "$INSTALL_DIR"
# Install binary
echo "📦 Installing rax to $INSTALL_DIR..."
cp "$RAX_BINARY" "$INSTALL_DIR/rax"
chmod +x "$INSTALL_DIR/rax"
echo ""
echo "✅ Rax installed successfully!"
echo ""
# Check if PATH includes ~/.local/bin
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo "⚠️ $HOME/.local/bin is not in your PATH"
echo ""
echo "Add this to your ~/.bashrc or ~/.zshrc:"
echo ""
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
fi
# Offer to add shell alias
echo "Would you like to add a shell alias for quicker access? [Y/n]"
read -r response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] || [[ -z "$response" ]]; then
# Detect shell
SHELL_RC=""
if [ -n "$ZSH_VERSION" ] || [ -f "$HOME/.zshrc" ]; then
SHELL_RC="$HOME/.zshrc"
elif [ -n "$BASH_VERSION" ] || [ -f "$HOME/.bashrc" ]; then
SHELL_RC="$HOME/.bashrc"
fi
if [ -n "$SHELL_RC" ]; then
# Check if alias already exists
if ! grep -q "alias rax=" "$SHELL_RC" 2>/dev/null; then
echo "" >> "$SHELL_RC"
echo "# Rax CLI alias" >> "$SHELL_RC"
echo "alias rax='$INSTALL_DIR/rax'" >> "$SHELL_RC"
echo "✅ Added alias to $SHELL_RC"
echo ""
echo "Run 'source $SHELL_RC' or restart your terminal to use 'rax' anywhere!"
else
echo "ℹ️ Alias already exists in $SHELL_RC"
fi
else
echo "Could not detect shell config file."
echo "Manually add this to your shell config:"
echo " alias rax='$INSTALL_DIR/rax'"
fi
fi
echo ""
echo "═══════════════════════════════════════════════════════════"
echo ""
echo "🎉 You're all set! Run 'rax' to start chatting!"
echo ""