#!/bin/bash

# Define color codes
declare -A colors
colors=(
    [black]='\[\e[30m\]'
    [red]='\[\e[31m\]'
    [green]='\[\e[32m\]'
    [yellow]='\[\e[33m\]'
    [blue]='\[\e[34m\]'
    [magenta]='\[\e[35m\]'
    [cyan]='\[\e[36m\]'
    [white]='\[\e[37m\]'
    [reset]='\[\e[0m\]'
)

# Parse arguments
color_name="$1"

# Validate color choice
if [[ -z "${colors[$color_name]}" ]]; then
    echo "Invalid color. Available options: ${!colors[@]}"
    exit 1
fi

# Backup .bashrc
cp ~/.bashrc ~/.bashrc.backup

# Remove existing PS1 color modifications
sed -i "s/\\\\\[\\\\e\[[0-9;]*m\\\\\]\\u@\\h:/${colors[$color_name]}\\u@\\h:/" ~/.bashrc

echo "Prompt color set to $color_name. Restart your terminal or run 'source ~/.bashrc' to apply changes."
