mortalscumbag.zsh-theme 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. function my_git_prompt() {
  2. tester=$(git rev-parse --git-dir 2> /dev/null) || return
  3. INDEX=$(git status --porcelain 2> /dev/null)
  4. STATUS=""
  5. # is branch ahead?
  6. if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
  7. STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
  8. fi
  9. # is anything staged?
  10. if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
  11. STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
  12. fi
  13. # is anything unstaged?
  14. if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then
  15. STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
  16. fi
  17. # is anything untracked?
  18. if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
  19. STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
  20. fi
  21. # is anything unmerged?
  22. if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
  23. STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
  24. fi
  25. if [[ -n $STATUS ]]; then
  26. STATUS=" $STATUS"
  27. fi
  28. echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
  29. }
  30. function my_current_branch() {
  31. echo $(current_branch || echo "(no branch)")
  32. }
  33. function ssh_connection() {
  34. if [[ -n $SSH_CONNECTION ]]; then
  35. echo "%{$fg_bold[red]%}(ssh) "
  36. fi
  37. }
  38. local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
  39. PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
  40. ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
  41. ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}"
  42. ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑"
  43. ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●"
  44. ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●"
  45. ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●"
  46. ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕"
  47. ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]›%{$reset_color%}"