Sun, 08 Jun 2014 03:52:31 -0400
Clone revision 002040b868ff
35
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1 | #!/usr/bin/env zsh |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3 | # ##### |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
4 | # this is just a tweaked nicoulaj.zsh-theme |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
5 | # ##### |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
6 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
7 | # ------------------------------------------------------------------------------ |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
8 | # Prompt for the Zsh shell: |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
9 | # * One line. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
10 | # * VCS info on the right prompt. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
11 | # * Only shows the path on the left prompt by default. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
12 | # * Crops the path to a defined length and only shows the path relative to |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
13 | # the current VCS repository root. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
14 | # * Wears a different color wether the last command succeeded/failed. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
15 | # * Shows user@hostname if connected through SSH. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
16 | # * Shows if logged in as root or not. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
17 | # ------------------------------------------------------------------------------ |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
18 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
19 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
20 | # Customizable parameters. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
21 | PROMPT_PATH_MAX_LENGTH=30 |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
22 | PROMPT_DEFAULT_END=❯ |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
23 | PROMPT_ROOT_END=❯❯❯ |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
24 | PROMPT_SUCCESS_COLOR=$FG[071] |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
25 | PROMPT_FAILURE_COLOR=$FG[124] |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
26 | PROMPT_VCS_INFO_COLOR=$FG[242] |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
27 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
28 | # Set required options. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
29 | setopt promptsubst |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
30 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
31 | # Load required modules. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
32 | autoload -U add-zsh-hook |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
33 | autoload -Uz vcs_info |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
34 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
35 | # Add hook for calling vcs_info before each command. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
36 | add-zsh-hook precmd vcs_info |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
37 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
38 | # Set vcs_info parameters. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
39 | zstyle ':vcs_info:*' enable git hg |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
40 | zstyle ':vcs_info:*:*' check-for-changes false # Can be slow on big repos. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
41 | zstyle ':vcs_info:*:*' unstagedstr '!' |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
42 | zstyle ':vcs_info:*:*' stagedstr '+' |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
43 | zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)" |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
44 | zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c" |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
45 | zstyle ':vcs_info:*:*' nvcsformats "%~" "" |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
46 | |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
47 | # Define prompts. |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
48 | 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]%} " |
41e83c36df2d
Clone revision 002040b868ff
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
49 | RPROMPT="%{$PROMPT_VCS_INFO_COLOR%}"'$vcs_info_msg_1_'"%{$FX[reset]%}" |