From f730f0f6045ff76a108abc53a27fd83f8edec171 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 30 Sep 2025 20:44:24 +0100 Subject: [PATCH] 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. --- bashrc | 18 ++++++++++++++++-- gitstatus-custom.sh | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bashrc b/bashrc index 0667594..9ef4f28 100644 --- a/bashrc +++ b/bashrc @@ -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 diff --git a/gitstatus-custom.sh b/gitstatus-custom.sh index dcfad5b..9513701 100644 --- a/gitstatus-custom.sh +++ b/gitstatus-custom.sh @@ -60,5 +60,5 @@ function my_gitstatus_prompt_update() { # Start gitstatusd and set up prompt command gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 -PROMPT_COMMAND=my_gitstatus_prompt_update +PROMPT_COMMAND="draw_prompt_divider; my_gitstatus_prompt_update" shopt -s promptvars \ No newline at end of file