-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·40 lines (33 loc) · 1.18 KB
/
install.sh
File metadata and controls
executable file
·40 lines (33 loc) · 1.18 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
#!/bin/bash
# Stop script on any error
set -e
echo "🦀 Building Rust shell in release mode..."
cargo build --release
# 1. Detect binary name from Cargo.toml
# If your binary name differs from the package name, hardcode BIN_NAME="your_name" below
PACKAGE_NAME=$(grep -m1 'name = ' Cargo.toml | cut -d '"' -f 2)
BIN_PATH="./target/release/$PACKAGE_NAME"
INSTALL_DIR="/usr/local/bin"
FINAL_PATH="$INSTALL_DIR/$PACKAGE_NAME"
if [ ! -f "$BIN_PATH" ]; then
echo "❌ Error: Could not find binary at $BIN_PATH"
echo " Ensure your crate name matches the binary name."
exit 1
fi
# 2. Install the binary
echo "📦 Installing '$PACKAGE_NAME' to $INSTALL_DIR..."
# sudo is required to write to /usr/local/bin on most setups
sudo cp "$BIN_PATH" "$FINAL_PATH"
sudo chmod +x "$FINAL_PATH"
# 3. Add to /etc/shells if missing
echo "📝 Checking /etc/shells..."
if grep -Fxq "$FINAL_PATH" /etc/shells; then
echo " Path already exists in /etc/shells. Skipping."
else
echo " Adding $FINAL_PATH to /etc/shells..."
echo "$FINAL_PATH" | sudo tee -a /etc/shells > /dev/null
fi
echo "✅ Success! Your shell is ready."
echo ""
echo "To switch to it immediately, run:"
echo "chsh -s $FINAL_PATH"