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:
parent
a2b0771c28
commit
f730f0f604
18
bashrc
18
bashrc
|
@ -125,11 +125,25 @@ function show_date() {
|
||||||
|
|
||||||
export HISTCONTROL=ignoreboth:erasedups
|
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
|
# Load custom gitstatus configuration
|
||||||
[ -f "$HOME/.config/bash/gitstatus-custom.sh" ] && . "$HOME/.config/bash/gitstatus-custom.sh"
|
[ -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
|
# Set PS1 with 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\]'
|
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
|
# If there are multiple matches for completion, Tab should cycle through them
|
||||||
bind TAB:menu-complete
|
bind TAB:menu-complete
|
||||||
|
|
|
@ -60,5 +60,5 @@ function my_gitstatus_prompt_update() {
|
||||||
|
|
||||||
# Start gitstatusd and set up prompt command
|
# Start gitstatusd and set up prompt command
|
||||||
gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1
|
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
|
shopt -s promptvars
|
Loading…
Reference in New Issue