forked from ChrisTitusTech/mybash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5df9dc2
commit 3a775e4
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
RC='\033[0m' | ||
RED='\033[31m' | ||
YELLOW='\033[33m' | ||
GREEN='\033[32m' | ||
|
||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1 | ||
} | ||
|
||
installRustAndBottom() { | ||
# Check if Rust is installed | ||
if command_exists rustc; then | ||
echo "Rust is already installed." | ||
return | ||
fi | ||
|
||
echo "${YELLOW}Installing Rust...${RC}" | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y | ||
|
||
# Source the Rust environment | ||
source "$HOME/.cargo/env" | ||
|
||
# Clone the bottom repository | ||
echo "${YELLOW}Cloning bottom repository...${RC}" | ||
BOTTOM_DIR="$HOME/bottom" | ||
if [ ! -d "$BOTTOM_DIR" ]; then | ||
git clone https://github.com/ClementTsang/bottom.git "$BOTTOM_DIR" | ||
else | ||
echo "Bottom repository already exists at $BOTTOM_DIR" | ||
fi | ||
|
||
# Build the bottom project | ||
echo "${YELLOW}Building bottom...${RC}" | ||
cd "$BOTTOM_DIR" && cargo build --release | ||
if [ $? -eq 0 ]; then | ||
echo "${GREEN}Bottom built successfully!${RC}" | ||
else | ||
echo "${RED}Failed to build bottom!${RC}" | ||
exit 1 | ||
fi | ||
|
||
# Cleanup: Remove the bottom directory | ||
echo "${YELLOW}Cleaning up by removing the bottom directory...${RC}" | ||
cd ~ # Navigate back to the home directory | ||
rm -rf "$BOTTOM_DIR" | ||
echo "${GREEN}Bottom directory removed successfully.${RC}" | ||
|
||
# Ask the user if they want to keep Rust | ||
read -p "Do you want to keep Rust installed? (y/n): " keep_rust | ||
if [[ "$keep_rust" =~ ^[Nn]$ ]]; then | ||
echo "${YELLOW}Removing Rust...${RC}" | ||
rustup self uninstall -y | ||
echo "${GREEN}Rust has been removed.${RC}" | ||
else | ||
echo "${GREEN}Rust will be kept.${RC}" | ||
fi | ||
} | ||
|
||
installRustAndBottom |