dieter.zsh-theme 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # the idea of this theme is to contain a lot of info in a small string, by compressing some parts,
  2. # and colorcoding, which bring useful visual cues. While limiting the amount of colors and such to keep
  3. # it easy on the eyes
  4. # exact return code (when >0) is on the right, so it stays out of the way
  5. # The visual cues for >0 exit codes will only display once
  6. # (i.e. they will be reset, even if you hit enter a few times on empty command prompts)
  7. typeset -A host_repr
  8. host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4")
  9. # local time, color coded after last return code
  10. time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
  11. time_disabled="%{$fg[green]%}%*%{$reset_color%}"
  12. time=$time_enabled
  13. # user part, color coded after privileges
  14. local user="%(!.%{$fg[blue]%}.%{$fg[blue]%})%n%{$reset_color%}"
  15. # Hostname part. compressed and colorcoded per host_repr array
  16. # if not found, regular hostname in default color
  17. local host="@${host_repr[$(hostname)]:-$(hostname)}%{$reset_color%}"
  18. # Compacted $PWD
  19. local pwd="%{$fg[blue]%}%c%{$reset_color%}"
  20. PROMPT='${time} ${user}${host} ${pwd} $(git_prompt_info)'
  21. # i would prefer 1 icon that shows the "most drastic" deviation from head, but lets see how this works out
  22. ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
  23. ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
  24. ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%} %{$fg[yellow]%}?%{$fg[green]%}%{$reset_color%}"
  25. ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%}"
  26. # elaborate exitcode on the right when >0
  27. return_code_enabled="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
  28. return_code_disabled=
  29. return_code=$return_code_enabled
  30. RPS1='${return_code}'
  31. function accept-line-or-clear-warning () {
  32. if [[ -z $BUFFER ]]; then
  33. time=$time_disabled
  34. return_code=$return_code_disabled
  35. else
  36. time=$time_enabled
  37. return_code=$return_code_enabled
  38. fi
  39. zle accept-line
  40. }
  41. zle -N accept-line-or-clear-warning
  42. bindkey '^M' accept-line-or-clear-warning