update
This commit is contained in:
parent
2419a843a3
commit
ee354503f2
2 changed files with 67 additions and 61 deletions
65
gitstatus-custom.sh
Normal file
65
gitstatus-custom.sh
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
# Custom gitstatus configuration with API-based prompt
|
||||
# Source this file from bashrc for git status in prompt
|
||||
|
||||
# Load gitstatus plugin for low-level API access
|
||||
[ -f "$HOME/.config/bash/gitstatus/gitstatus.plugin.sh" ] && . "$HOME/.config/bash/gitstatus/gitstatus.plugin.sh"
|
||||
|
||||
# Custom gitstatus prompt function (replicates default behavior with customizations)
|
||||
function my_gitstatus_prompt_update() {
|
||||
GITSTATUS_PROMPT=""
|
||||
|
||||
gitstatus_query || return 1 # error
|
||||
[[ "$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 red=$'\001\e[38;5;196m\002' # red - urgent attention (conflicts, merge)
|
||||
|
||||
local p
|
||||
|
||||
# Branch name, tag or commit
|
||||
local where
|
||||
if [[ -n "$VCS_STATUS_LOCAL_BRANCH" ]]; then
|
||||
where="$VCS_STATUS_LOCAL_BRANCH"
|
||||
elif [[ -n "$VCS_STATUS_TAG" ]]; then
|
||||
p+="${reset}#"
|
||||
where="$VCS_STATUS_TAG"
|
||||
else
|
||||
p+="${reset}@"
|
||||
where="${VCS_STATUS_COMMIT:0:8}"
|
||||
fi
|
||||
|
||||
# Truncate long branch names and tags
|
||||
(( ${#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}"
|
||||
(( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && p+=" "
|
||||
(( VCS_STATUS_COMMITS_AHEAD )) && p+="${yellow}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}"
|
||||
(( 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}"
|
||||
|
||||
# CUSTOM: Stashes with "stash:" prefix instead of "*"
|
||||
(( VCS_STATUS_STASHES )) && p+=" ${reset}stashed:${VCS_STATUS_STASHES}"
|
||||
|
||||
# Repository state and file counts (descriptive labels)
|
||||
[[ -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}"
|
||||
|
||||
GITSTATUS_PROMPT="${p}${reset}"
|
||||
}
|
||||
|
||||
# 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
|
||||
shopt -s promptvars
|
||||
Loading…
Add table
Add a link
Reference in a new issue