mirror of
https://github.com/danbee/dotfiles-local
synced 2025-03-04 08:49:07 +00:00
67 lines
1.5 KiB
Plaintext
67 lines
1.5 KiB
Plaintext
source $(brew --prefix)/opt/gitstatus/gitstatus.plugin.zsh MY
|
||
|
||
gitstatus_startMY MY
|
||
|
||
export GIT_PROMPT=""
|
||
|
||
update_git_prompt() {
|
||
typeset -g GIT_PROMPT=""
|
||
|
||
gitstatus_queryMY 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%} "
|
||
}
|
||
|
||
os_icon() {
|
||
case $(uname) in
|
||
Darwin)
|
||
echo "%{$fg[white]%} macOS%{$reset_color%}"
|
||
;;
|
||
Linux)
|
||
echo "%{$fg[yellow]%} Linux%{$reset_color%}"
|
||
;;
|
||
FreeBSD)
|
||
echo "%{$fg[red]%} FreeBSD%{$reset_color%}"
|
||
;;
|
||
OpenBSD)
|
||
echo "%{$fg[yellow]%}OpenBSD%{$reset_color%}"
|
||
;;
|
||
esac
|
||
}
|
||
|
||
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='$(os_icon) ${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
|