add prompt divider and update command for gitstatus

Introduced a function to draw a terminal-width divider with a timestamp
and updated the PROMPT_COMMAND to include this new function for better
visual separation in the terminal prompt.
This commit is contained in:
Ray Elliott 2025-09-30 20:44:24 +01:00
commit f730f0f604
2 changed files with 17 additions and 3 deletions

18
bashrc
View file

@ -125,11 +125,25 @@ function show_date() {
export HISTCONTROL=ignoreboth:erasedups
# Function to draw a terminal-width divider line with timestamp
function draw_prompt_divider() {
local width=${COLUMNS:-80} # Use terminal width, fallback to 80
local timestamp=$(date '+%H:%M:%S')
local prefix="$timestamp ├"
local prefix_length=${#prefix}
local line_length=$((width - prefix_length))
# Print timestamp + junction + line to fill remaining width
printf '%s' "$prefix"
printf '%.0s─' $(seq 1 $line_length)
echo
}
# 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[1;34m\]\w\[\033[00m\]\n${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT\n}\[\033[01;$((31+!$?))m\]\$\[\033[00m\] \[\e]0;\u@\h: \w\a\]'
# Set PS1 with user@host, directory on first line, git status on second line, prompt on third line
PS1='\[\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