-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (89 loc) · 2.64 KB
/
install.sh
File metadata and controls
executable file
·103 lines (89 loc) · 2.64 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
#!/bin/bash
set -e
# AL installer script
# Usage: curl -fsSL al.alistair.sh/install.sh | bash
INSTALL_DIR="$HOME/.al/bin"
BINARY_NAME="al"
REPO="alii/al"
echo "Installing AL..."
# Detect architecture
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH="x86_64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
# Detect OS
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case $OS in
darwin) OS="macos" ;;
linux) OS="linux" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
ASSET_NAME="al-$OS-$ARCH"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/canary/$ASSET_NAME"
# Create install directory
mkdir -p "$INSTALL_DIR"
curl -fsSL "$DOWNLOAD_URL" -o "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
echo "Installed AL to $INSTALL_DIR/$BINARY_NAME"
# Add to PATH if not already there
add_to_path() {
local rc_file="$1"
local shell_name="$2"
if [ -f "$rc_file" ]; then
if ! grep -q 'export PATH="$HOME/.al/bin:$PATH"' "$rc_file" 2>/dev/null; then
echo "" >> "$rc_file"
echo '# AL' >> "$rc_file"
echo 'export PATH="$HOME/.al/bin:$PATH"' >> "$rc_file"
echo "Added ~/.al/bin to PATH in $rc_file"
return 0
else
return 1 # Already in PATH
fi
fi
return 2 # File doesn't exist
}
PATH_ADDED=false
SHELL_NAME=$(basename "$SHELL")
case $SHELL_NAME in
zsh)
if add_to_path "$HOME/.zshrc" "zsh"; then
PATH_ADDED=true
fi
;;
bash)
# Try .bashrc first, then .bash_profile
if add_to_path "$HOME/.bashrc" "bash"; then
PATH_ADDED=true
elif add_to_path "$HOME/.bash_profile" "bash"; then
PATH_ADDED=true
fi
;;
fish)
FISH_CONFIG="$HOME/.config/fish/config.fish"
if [ -f "$FISH_CONFIG" ]; then
if ! grep -q 'set -gx PATH $HOME/.al/bin $PATH' "$FISH_CONFIG" 2>/dev/null; then
echo "" >> "$FISH_CONFIG"
echo "# AL" >> "$FISH_CONFIG"
echo 'set -gx PATH $HOME/.al/bin $PATH' >> "$FISH_CONFIG"
echo "Added ~/.al/bin to PATH in $FISH_CONFIG"
PATH_ADDED=true
fi
fi
;;
esac
echo ""
if [ "$PATH_ADDED" = true ]; then
echo "Restart your shell or run:"
echo " source ~/.$SHELL_NAME*rc"
echo ""
echo "Then run 'al' to get started"
elif echo "$PATH" | grep -q "$HOME/.al/bin"; then
echo "Run 'al' to get started"
else
echo "Add ~/.al/bin to your PATH:"
echo " export PATH=\"\$HOME/.al/bin:\$PATH\""
echo ""
echo "Then run 'al' to get started"
fi