scripts/bash/bash_tui.sh
2025-04-14 09:22:15 +02:00

106 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Menu options
declare -a options=(
"Dotfiles"
"CLI Tool Installation"
"Sudo-Options"
"Optimizations"
"Exit"
)
# declare -a options="Dotfiles CLI_Tool_Installation Sudo-Options Optimizations Exit"
# Function to print colored text
print_color() {
printf "%b%s%b\n" "$1" "$2" "$NC"
}
# Function to display the menu
display_menu() {
clear
print_color "$BLUE" "=== Environment Setup Menu ==="
for i in "${!options[@]}"; do
if [[ $i -eq $selected ]]; then
print_color "$GREEN" "> ${options[$i]}"
else
echo " ${options[$i]}"
fi
done
}
# Function to handle dotfiles setup
dotfiles_setup() {
print_color "$YELLOW" "Setting up dotfiles..."
# Add your dotfiles setup logic here
sleep 2
}
# Function to handle CLI tool installation
cli_tool_installation() {
print_color "$YELLOW" "Installing CLI tools..."
# Add your CLI tool installation logic here
sleep 2
}
# Function to handle optimizations
optimizations() {
print_color "$YELLOW" "Performing optimizations..."
# Add your optimization logic here
sleep 2
}
sudo_options() {
if [[ -e /etc/sudoers ]]; then
echo "Defaults pwfeedback" | tee -a /etc/sudoers
echo "Defaults insults" | tee -a /etc/sudoers
else
echo_error "There is no /etc/sudoers file."
fi
}
# Main menu loop
main_menu() {
local selected=0
local key=""
while true; do
display_menu
# Read a single character
read -rsn1 key
case $key in
A | k) # Up arrow or k
((selected--))
if [[ $selected -lt 0 ]]; then
selected=$((${#options[@]} - 1))
fi
;;
B | j) # Down arrow or j
((selected++))
if [[ $selected -ge ${#options[@]} ]]; then
selected=0
fi
;;
"") # Enter key
case $selected in
0) dotfiles_setup ;;
1) cli_tool_installation ;;
2) sudo_options ;;
3) optimizations ;;
4) exit 0 ;;
esac
;;
esac
done
}
# Start the main menu
main_menu </dev/tty