Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function git_prompt_info() {
- local COLOR="%{$fg_bold[magenta]%}"
- local REF
- local STATUS
- local DIRTY
- local DIRTYM
- local DIRTYA
- local DIRTYD
- REF=$(command git symbolic-ref HEAD --short 2> /dev/null)
- if [[ -z $REF ]]; then
- REF=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
- fi
- STATUS=$(command git status --porcelain)
- if [[ -n $STATUS ]]; then
- DIRTY="*"
- DIRTYM=$(command echo "$STATUS" | grep "^ M" | wc -l 2> /dev/null)
- if [[ $DIRTYM -gt 0 ]]; then
- DIRTY="$DIRTY %{$fg_bold[blue]%}±$DIRTYM$COLOR"
- fi
- DIRTYA=$(command echo "$STATUS" | grep "^??" | wc -l 2> /dev/null)
- if [[ $DIRTYA -gt 0 ]]; then
- DIRTY="$DIRTY %{$fg_bold[green]%}+$DIRTYA$COLOR"
- fi
- DIRTYD=$(command echo "$STATUS" | grep "^ D" | wc -l 2> /dev/null)
- if [[ $DIRTYD -gt 0 ]]; then
- DIRTY="$DIRTY %{$fg_bold[red]%}-$DIRTYD$COLOR"
- fi
- fi
- echo "$COLOR‹${REF}${DIRTY}›%{$reset_color%}"
- }
- local return_code="%(?..%{$bg[red]%}%{$fg_bold[white]%} ret → %?
- %{$reset_color%})"
- local prefix_top='%{$fg[cyan]%}╭─%{$reset_color%}'
- local prefix_bottom='%{$fg[cyan]%}╰─%{$reset_color%}'
- local user_host='%{$fg[cyan]%}%n@%m%{$reset_color%}'
- local current_dir='%{$fg_bold[blue]%}%~%{$reset_color%}'
- local git_branch='$(git_prompt_info)'
- PROMPT="${return_code}${prefix_top} ${user_host} ${current_dir} ${git_branch}
- ${prefix_bottom} "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement