Bash prompt themes, with a color gradient feature.
Themes are a combination of a template and a color palette. The template is the prompt itself and the colors from the palette are applied onto it.
Theme names are a combinasion of their template and palette: template_palette like teal_horizon.
Demo all the themes using:
./demo_themesTo use a theme simply source it to your current shell:
source ./themes/teal_horizonClone the repo on your machine because themes aren't fully standalone, they use the lib/lib file from this repo.
Source the theme in your .bashrc. For instance, at the end of your .bashrc, add:
# Change the path with where you put bash-ps1-themes source ~/bash-ps1-themes/themes/teal_cyber_3The themes work with the PROMPT_COMMAND and PS1 environment variable.
The PROMPT_COMMAND invokes a function that in turn invokes other functions to build a PS1 variable.
You can create your own templates and color palettes.
Create a new file in the palettes/ folder and update the following variables to your liking:
#!/bin/bash palette_primary="#1bcfc6" palette_primary_dark="#02a199" palette_secondary="#008cff" palette_secondary_dark="#0066ba" palette_accent="#b88914" palette_accent_dark="#9c7f0c" palette_gradient_start="#0bb092" palette_gradient_end="#008cff" palette_variant_1="#00d7af" palette_variant_2="#00d7d7" palette_variant_3="#00d7ff"To preview the palette in the terminal, use:
./demo_palettes./demo_palettes --detailedCreate a new file in the templates/ folder.
This snippet is an example of a basic template:
#!/bin/bash scriptDir=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") source $scriptDir'/../lib/lib' prompt_cmd() { LINE_1="$(rgb_fg_ps1 $palette_primary)$(current_user) $(rgb_fg_ps1 $palette_secondary)$(basename $PWD)" LINE_2="$(rgb_fg_ps1 $palette_accent)$ $(no_color_ps1)" PS1="\r\n${LINE_1}\r\n${LINE_2}" } export PROMPT_COMMAND='prompt_cmd'Here are some functions you can use in your templates:
# Set the foreground color, all text set after calling this function will be the desired color rgb_fg_ps1 "#ffffff" # Set the background color, all text set after calling this function will be the desired color rgb_bg_ps1 "#ffffff" # Create a foreground gradient over a defined string fg_gradient_ps1 "#ff0000" "#00ff00" "some string to receive gradient" # Create a background gradient over a defined string bg_gradient_ps1 "#ff0000" "#00ff00" "some string to receive gradient" # Current git branch gitbranchSee the lib/ source for more functions.
Then, to apply the palette to the templates, there is a generate_themes script that combines all sets of templates and palettes together:
./generate_themesYour theme will be generated in the themes/ folder.
Works only in Bash shells.





