mirror of
https://github.com/danbee/dotfiles-local
synced 2025-03-04 08:49:07 +00:00
50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
source "$HOME/.zsh/lib/gitstatus/gitstatus.plugin.zsh"
|
||
|
||
gitstatus_start MY
|
||
|
||
export GIT_PROMPT=""
|
||
|
||
update_git_prompt() {
|
||
typeset -g GIT_PROMPT=""
|
||
|
||
gitstatus_query -t 5 MY || return
|
||
[[ $VCS_STATUS_RESULT == ok-sync ]] || return
|
||
|
||
GIT_PROMPT+="%{$fg[blue]%}[%{$fg_bold[blue]%}${VCS_STATUS_LOCAL_BRANCH}%{$reset_color%}"
|
||
|
||
if [[ $VCS_STATUS_HAS_STAGED == 1 ]]; then
|
||
GIT_PROMPT+="%{$fg_bold[yellow]%}+%{$reset_color%}"
|
||
fi
|
||
|
||
if [[ $VCS_STATUS_HAS_UNSTAGED == 1 ]]; then
|
||
GIT_PROMPT+="%{$fg_bold[red]%}∗%{$reset_color%}"
|
||
fi
|
||
|
||
GIT_PROMPT+="%{$fg[blue]%}]%{$reset_color%} "
|
||
}
|
||
|
||
autoload -Uz add-zsh-hook
|
||
|
||
add-zsh-hook precmd update_git_prompt
|
||
|
||
# makes color constants available
|
||
autoload -U colors
|
||
colors
|
||
|
||
# enable colored output from ls, etc
|
||
export CLICOLOR=1
|
||
|
||
# expand functions in the prompt
|
||
setopt promptsubst
|
||
|
||
# prompt
|
||
export PROMPT='${SSH_CONNECTION+"%{$fg[yellow]%}%n@%m%{$reset_color%}:"}%{$fg_bold[green]%}%2c%{$reset_color%} ${GIT_PROMPT}%{$fg_bold[cyan]%}❯%{$reset_color%} '
|
||
export RPROMPT='%D{%K:%M:%S}'
|
||
|
||
# update the prompt on carriage return
|
||
function _reset-prompt-and-accept-line() {
|
||
zle reset-prompt
|
||
zle .accept-line
|
||
}
|
||
zle -N accept-line _reset-prompt-and-accept-line
|