Skip to content

Commit

Permalink
Create bottom.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmistry2000 authored Sep 25, 2024
1 parent 5df9dc2 commit 3a775e4
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions bottom.sh
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

0 comments on commit 3a775e4

Please sign in to comment.