1
|
1
|
new file mode 100644
|
...
|
...
|
@@ -0,0 +1,43 @@
|
|
0
|
+#!/usr/bin/env zsh
|
|
1
|
+# ------------------------------------------------------------------------------
|
|
2
|
+# Prompt for the Zsh shell:
|
|
3
|
+# * One line.
|
|
4
|
+# * VCS info on the right prompt.
|
|
5
|
+# * Only shows the path on the left prompt by default.
|
|
6
|
+# * Crops the path to a defined length and only shows the path relative to
|
|
7
|
+# the current VCS repository root.
|
|
8
|
+# * Wears a different color wether the last command succeeded/failed.
|
|
9
|
+# * Shows user@hostname if connected through SSH.
|
|
10
|
+# * Shows if logged in as root or not.
|
|
11
|
+# ------------------------------------------------------------------------------
|
|
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
|
+
|
|
21
|
+# Set required options.
|
|
22
|
+setopt promptsubst
|
|
23
|
+
|
|
24
|
+# Load required modules.
|
|
25
|
+autoload -U add-zsh-hook
|
|
26
|
+autoload -Uz vcs_info
|
|
27
|
+
|
|
28
|
+# Add hook for calling vcs_info before each command.
|
|
29
|
+add-zsh-hook precmd vcs_info
|
|
30
|
+
|
|
31
|
+# Set vcs_info parameters.
|
|
32
|
+zstyle ':vcs_info:*' enable hg bzr git
|
|
33
|
+zstyle ':vcs_info:*:*' check-for-changes true # Can be slow on big repos.
|
|
34
|
+zstyle ':vcs_info:*:*' unstagedstr '!'
|
|
35
|
+zstyle ':vcs_info:*:*' stagedstr '+'
|
|
36
|
+zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)"
|
|
37
|
+zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c"
|
|
38
|
+zstyle ':vcs_info:*:*' nvcsformats "%$PROMPT_PATH_MAX_LENGTH<..<%~%<<" ""
|
|
39
|
+
|
|
40
|
+# Define prompts.
|
|
41
|
+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]%} "
|
|
42
|
+RPROMPT="%{$PROMPT_VCS_INFO_COLOR%}"'$vcs_info_msg_1_'"%{$FX[reset]%}"
|