diff --git a/bashrc b/bashrc index 2a5adfd..c7991c9 100644 --- a/bashrc +++ b/bashrc @@ -1,5 +1,29 @@ +# Color definitions _WHITE='\033[1;37m' # White -_NC='\033[0m' # No Color +_NC='\033[0m' # Get the current day of the week, day of the month, and year + day_of_week=$(date "+%A") + day_of_month=$(date "+%d") + month_name=$(date "+%B") + year=$(date "+%Y") + + # Determine the day suffix (th, nd, rd) + case "$day_of_month" in + 1[0-9]) day_suffix="th";; + *1) day_suffix="st";; + *2) day_suffix="nd";; + *3) day_suffix="rd";; + *) day_suffix="th";; + esac + + # Determine the color based on the classification # No Color / Reset +_RED='\033[0;31m' # Red +_GREEN='\033[01;32m' # Bright Green +_YELLOW='\033[0;33m' # Yellow +_BLUE='\033[1;34m' # Bright Blue +_BRIGHT_GREEN='\033[1;32m' # Bright Green (for positive) +_BRIGHT_RED='\033[1;31m' # Bright Red (for negative) +_BRIGHT_WHITE='\033[1;37m' # Bright White +_DIM_RED='\033[91m' # Bright Red (for TODO files) export SHELL_CONFIG="$SHELL_CONFIG:.bashrc" # @@ -62,17 +86,6 @@ function show_date() { # Split the selected adjective into the adjective and classification parts IFS=':' read -r adjective classification <<< "$selected_adjective" - # Determine the color code based on the classification - case "$classification" in - "positive") text_color="\033[1;32m";; - "negative") text_color="\033[1;31m";; - *) text_color="";; # Default to no colour - esac - - # ANSI escape codes for reset - reset_color='\033[0m' - hl_color='\033[1;34m' - # Get the current day of the week, day of the month, and year day_of_week=$(date "+%A") day_of_month=$(date "+%d") @@ -88,8 +101,15 @@ function show_date() { *) day_suffix="th";; esac + # Determine the color based on the classification + case "$classification" in + "positive") text_color="$_BRIGHT_GREEN";; + "negative") text_color="$_BRIGHT_RED";; + *) text_color="";; + esac + # Create the full date format with colored parts and the selected adjective - full_date="Pray, be informed, on this ${text_color}${adjective}${reset_color} day,\n${hl_color}${day_of_week}${reset_color} the ${hl_color}${day_of_month}${day_suffix}${reset_color} day of ${hl_color}${month_name}${reset_color}, in the year of our Lord ${hl_color}${year}${reset_color}!" + full_date="Pray, be informed, on this ${text_color}${adjective}${_NC} day,\n${_BLUE}${day_of_week}${_NC} the ${_BLUE}${day_of_month}${day_suffix}${_NC} day of ${_BLUE}${month_name}${_NC}, in the year of our Lord ${_BLUE}${year}${_NC}!" # Print the full date echo -e "$full_date" @@ -100,13 +120,17 @@ function show_date() { # If not running interactively, don't do anything [[ $- != *i* ]] && return +# ============================================================================ +# SHELL CONFIGURATION +# ============================================================================ + export HISTCONTROL=ignoreboth:erasedups # Load custom gitstatus configuration [ -f "$HOME/.config/bash/gitstatus-custom.sh" ] && . "$HOME/.config/bash/gitstatus-custom.sh" # Set PS1 with time, user@host, directory on first line, git status on second line, prompt on third line -PS1='\t \[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\n${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT\n}\[\033[01;$((31+!$?))m\]\$\[\033[00m\] \[\e]0;\u@\h: \w\a\]' +PS1='\t \[\033[01;32m\]\u@\h\[\033[00m\] \[\033[1;34m\]\w\[\033[00m\]\n${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT\n}\[\033[01;$((31+!$?))m\]\$\[\033[00m\] \[\e]0;\u@\h: \w\a\]' # If there are multiple matches for completion, Tab should cycle through them bind TAB:menu-complete @@ -138,45 +162,45 @@ echo -e " ${_WHITE}lftp cheat vimv 'flameshot gui' rclone mid3v2 zathura tessera echo "" if [ ${_mem_available%.*} -lt 5 ] ; then - echo -ne "Memory available: \033[0;33m" - [ ${_mem_available%.*} -lt 3 ] && echo -ne "\033[0;31m" + echo -ne "Memory available: ${_YELLOW}" + [ ${_mem_available%.*} -lt 3 ] && echo -ne "${_RED}" echo -n "${_mem_available}" - echo -e "GB\033[0m" + echo -e "GB${_NC}" fi if [ $_updates_available -gt 0 ] ; then - update_color="\033[1;37m" # default white + update_color="$_BRIGHT_WHITE" # default white if [ $_updates_available -gt 29 ] ; then - update_color="\033[0;31m" # red + update_color="$_RED" # red elif [ $_updates_available -gt 15 ] ; then - update_color="\033[0;33m" # yellow + update_color="$_YELLOW" # yellow fi - echo -ne "Updates available: ${update_color}${_updates_available}\033[0m" - echo -ne " [ update with: ${update_color}update\033[0m ]" + echo -ne "Updates available: ${update_color}${_updates_available}${_NC}" + echo -ne " [ update with: ${update_color}update${_NC} ]" echo "" fi _orphans_available="$(pacman -Qdtq 2>/dev/null | wc -l)" if [ $_orphans_available -gt 0 ] ; then - echo -ne "Orphaned packages: \033[1;37m" + echo -ne "Orphaned packages: $_BRIGHT_WHITE" - orphan_color="\033[1;37m" + orphan_color="$_BRIGHT_WHITE" if [ $_orphans_available -gt 9 ] ; then - orphan_color="\033[0;31m" + orphan_color="$_RED" elif [ $_orphans_available -gt 4 ] ; then - orphan_color="\033[0;33m" + orphan_color="$_YELLOW" fi - echo -ne "${orphan_color}${_orphans_available}\033[0m" - echo -ne " [ remove with: ${orphan_color}sudo pacman -Rns \$(pacman -Qdtq)\033[0m ]" + echo -ne "${orphan_color}${_orphans_available}${_NC}" + echo -ne " [ remove with: ${orphan_color}sudo pacman -Rns \$(pacman -Qdtq)${_NC} ]" echo "" fi echo "" -echo -e "Remember \"\033[1;34mTODO.md\033[0m\" and \"\033[1;34mautonote.md\033[0m\" files have content automatically displayed." -echo -e "Edit these with \033[1;34met\033[0m and \033[1;34mea\033[0m" +echo -e "Remember \"${_BLUE}TODO.md${_NC}\" and \"${_BLUE}autonote.md${_NC}\" files have content automatically displayed." +echo -e "Edit these with ${_BLUE}et${_NC} and ${_BLUE}ea${_NC}" echo "" . "$HOME/.config/bash/cheat.bash" @@ -193,7 +217,7 @@ alias backup='sudo borgmatic create --verbosity 1 --files' function check_todo() { if [ -f "TODO.md" ]; then echo - echo -e "\e[91mTODO.md\e[0m" + echo -e "${_DIM_RED}TODO.md${_NC}" echo "---------------------------" mdcat TODO.md echo "---------------------------" @@ -204,7 +228,7 @@ fi function check_autonote() { if [ -f ".autonote.md" ]; then echo - echo -e "\e[91mautonote.md\e[0m" + echo -e "${_DIM_RED}autonote.md${_NC}" echo "---------------------------" mdcat .autonote.md echo "---------------------------" diff --git a/gitstatus-custom.sh b/gitstatus-custom.sh index b4bfded..2c46cda 100644 --- a/gitstatus-custom.sh +++ b/gitstatus-custom.sh @@ -13,9 +13,7 @@ function my_gitstatus_prompt_update() { [[ "$VCS_STATUS_RESULT" == ok-sync ]] || return 0 # not a git repo local reset=$'\001\e[0m\002' # no color - local green=$'\001\e[38;5;076m\002' # green - clean branch name - local blue=$'\001\e[38;5;014m\002' # blue - informational (untracked) - local yellow=$'\001\e[38;5;011m\002' # yellow - action pending (staged, behind/ahead) + local green=$'\001\e[38;5;076m\002' # green - clean branch name only local red=$'\001\e[38;5;196m\002' # red - urgent attention (conflicts, merge) local p @@ -36,25 +34,25 @@ function my_gitstatus_prompt_update() { (( ${#where} > 32 )) && where="${where:0:12}…${where: -12}" p+="${green}${where}" - # Remote tracking status (yellow - action pending) - (( VCS_STATUS_COMMITS_BEHIND )) && p+=" ${yellow}behind:${VCS_STATUS_COMMITS_BEHIND}" + # Remote tracking status (no color - less distracting) + (( VCS_STATUS_COMMITS_BEHIND )) && p+=" ${reset}behind:${VCS_STATUS_COMMITS_BEHIND}" (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && p+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && p+="${yellow}ahead:${VCS_STATUS_COMMITS_AHEAD}" + (( VCS_STATUS_COMMITS_AHEAD )) && p+="${reset}ahead:${VCS_STATUS_COMMITS_AHEAD}" - # Push remote status (yellow - action pending) - (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" ${yellow}push-behind:${VCS_STATUS_PUSH_COMMITS_BEHIND}" + # Push remote status (no color - less distracting) + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" ${reset}push-behind:${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && p+=" " - (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && p+="${yellow}push-ahead:${VCS_STATUS_PUSH_COMMITS_AHEAD}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && p+="${reset}push-ahead:${VCS_STATUS_PUSH_COMMITS_AHEAD}" # CUSTOM: Stashes with "stash:" prefix instead of "*" (( VCS_STATUS_STASHES )) && p+=" ${reset}stashed:${VCS_STATUS_STASHES}" - # Repository state and file counts (descriptive labels) + # Repository state and file counts (minimal colors) [[ -n "$VCS_STATUS_ACTION" ]] && p+=" ${red}${VCS_STATUS_ACTION}" (( VCS_STATUS_NUM_CONFLICTED )) && p+=" ${red}conflicts:${VCS_STATUS_NUM_CONFLICTED}" - (( VCS_STATUS_NUM_STAGED )) && p+=" ${yellow}staged:${VCS_STATUS_NUM_STAGED}" - (( VCS_STATUS_NUM_UNSTAGED )) && p+=" ${yellow}modified:${VCS_STATUS_NUM_UNSTAGED}" - (( VCS_STATUS_NUM_UNTRACKED )) && p+=" ${blue}untracked:${VCS_STATUS_NUM_UNTRACKED}" + (( VCS_STATUS_NUM_STAGED )) && p+=" ${reset}staged:${VCS_STATUS_NUM_STAGED}" + (( VCS_STATUS_NUM_UNSTAGED )) && p+=" ${reset}modified:${VCS_STATUS_NUM_UNSTAGED}" + (( VCS_STATUS_NUM_UNTRACKED )) && p+=" ${reset}untracked:${VCS_STATUS_NUM_UNTRACKED}" GITSTATUS_PROMPT="${p}${reset}" }