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.

43 lines
1.6 KiB

3 years ago
  1. #!/usr/bin/env zsh
  2. # ------------------------------------------------------------------------------
  3. # Prompt for the Zsh shell:
  4. # * One line.
  5. # * VCS info on the right prompt.
  6. # * Only shows the path on the left prompt by default.
  7. # * Crops the path to a defined length and only shows the path relative to
  8. # the current VCS repository root.
  9. # * Wears a different color whether the last command succeeded/failed.
  10. # * Shows user@hostname if connected through SSH.
  11. # * Shows if logged in as root or not.
  12. # ------------------------------------------------------------------------------
  13. # Customizable parameters.
  14. PROMPT_PATH_MAX_LENGTH=30
  15. PROMPT_DEFAULT_END=❯
  16. PROMPT_ROOT_END=❯❯❯
  17. PROMPT_SUCCESS_COLOR=$FG[071]
  18. PROMPT_FAILURE_COLOR=$FG[124]
  19. PROMPT_VCS_INFO_COLOR=$FG[242]
  20. # Set required options.
  21. setopt promptsubst
  22. # Load required modules.
  23. autoload -U add-zsh-hook
  24. autoload -Uz vcs_info
  25. # Add hook for calling vcs_info before each command.
  26. add-zsh-hook precmd vcs_info
  27. # Set vcs_info parameters.
  28. zstyle ':vcs_info:*' enable hg bzr git
  29. zstyle ':vcs_info:*:*' check-for-changes true # Can be slow on big repos.
  30. zstyle ':vcs_info:*:*' unstagedstr '!'
  31. zstyle ':vcs_info:*:*' stagedstr '+'
  32. zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)"
  33. zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c"
  34. zstyle ':vcs_info:*:*' nvcsformats "%~" ""
  35. # Define prompts.
  36. PROMPT="%(0?.%{$PROMPT_SUCCESS_COLOR%}.%{$PROMPT_FAILURE_COLOR%})${SSH_TTY:+[%n@%m]}%{$FX[bold]%}%$PROMPT_PATH_MAX_LENGTH<..<"'${vcs_info_msg_0_%%.}'"%<<%(!.$PROMPT_ROOT_END.$PROMPT_DEFAULT_END)%{$FX[no-bold]%}%{$FX[reset]%} "
  37. RPROMPT="%{$PROMPT_VCS_INFO_COLOR%}"'$vcs_info_msg_1_'"%{$FX[reset]%}"