bash-git-prompt/gpchange.sh

44 lines
1.6 KiB
Bash
Raw Permalink Normal View History

2025-02-03 12:59:23 +01:00
#!/bin/bash
#####################################################################################
# First Created: 14012025 Author: Allan Desc: Changes the theme for bash-git-prompt #
#####################################################################################
#
# Define variables and functions
#
themedir="$HOME/.bash-git-prompt/themes"
allthemes=$(ls -la $themedir |grep "bgptheme" |sed s'/.bgptheme//g' |awk '{print $9}')
activetheme=$(cat /$HOME/.bashrc |grep "GIT_PROMPT_THEME" |awk -F'=' '{print $2}')
#
# Define colors
#
redbc=$(echo "\e[38;5;196;1m")
cyanbc=$(echo "\e[38;5;117;1m")
resetc=$(echo "\e[0m")
clear
cd $themedir
if [ -z "$activetheme" ] ; then printf "\n${redbc}Error! ${resetc}GIT_PROMPT_THEME not found in .bashrc\n\n" ; exit ; fi
printf "Bash Git Promt Theme Changer - Use CTRL+C to quit...\n\n"
printf "Current Theme = ${cyanbc}$activetheme${resetc}\n\n"
printf "Available Themes:\n\n"
printf '%s\n' "${allthemes[@]}"
printf "\n"
read -p "Enter Theme Name To Use: " themename
if [[ ${allthemes[*]} =~ (^|[[:space:]])"$themename"($|[[:space:]]) ]] ; then proceed="yes" ; else proceed="no" ; fi
if [[ $proceed == "no" ]] ; then printf "\n${redbc}Error! ${resetc}The theme ${redbc}$themename${resetc} does not exist...\n\n" ; exit ; fi
if [[ $themename == "$activetheme" ]] ; then printf "\nYou are allready using the theme ${cyanbc}$themename${resetc} nothing to do...\n\n" ; exit ; fi
sed -i "s/THEME=.*$/THEME=$themename/" $HOME/.bashrc
printf "\nTheme changed to ${cyanbc}$themename${resetc} please close and reopen all your terminals for changes to take effect.\n\n"
#
# End of script
#