my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
2.0 KiB

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