Parent directory

nicoulaj.zsh-theme

1832 bytes
 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
14# Customizable parameters.
15PROMPT_PATH_MAX_LENGTH=${PROMPT_PATH_MAX_LENGTH:-30}
16PROMPT_DEFAULT_END=${PROMPT_DEFAULT_END:-❯}
17PROMPT_ROOT_END=${PROMPT_ROOT_END:-❯❯❯}
18PROMPT_SUCCESS_COLOR=${PROMPT_SUCCESS_COLOR:-$FG[071]}
19PROMPT_FAILURE_COLOR=${PROMPT_FAILURE_COLOR:-$FG[124]}
20PROMPT_VCS_INFO_COLOR=${PROMPT_VCS_INFO_COLOR:-$FG[242]}
21
22# Set required options.
23setopt promptsubst
24
25# Load required modules.
26autoload -U add-zsh-hook
27autoload -Uz vcs_info
28
29# Add hook for calling vcs_info before each command.
30add-zsh-hook precmd vcs_info
31
32# Set vcs_info parameters.
33zstyle ':vcs_info:*' enable hg bzr git
34zstyle ':vcs_info:*:*' check-for-changes true # Can be slow on big repos.
35zstyle ':vcs_info:*:*' unstagedstr '!'
36zstyle ':vcs_info:*:*' stagedstr '+'
37zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)"
38zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c"
39zstyle ':vcs_info:*:*' nvcsformats "%~" ""
40
41# Define prompts.
42PROMPT="%(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]%} "
43RPROMPT="%{$PROMPT_VCS_INFO_COLOR%}"'$vcs_info_msg_1_'"%{$FX[reset]%}"