From c53ab8ee011a6c8483796aaa202d43478b3f65b0 Mon Sep 17 00:00:00 2001 From: Julien Nicoulaud Date: Sat, 20 Nov 2010 18:06:23 +0100 Subject: [PATCH 1/3] Rename appearance.zsh so that it gets loaded after spectrum.zsh. Allows to use 256 colors in prompt themes. --- lib/{appearance.zsh => theme-and-appearance.zsh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{appearance.zsh => theme-and-appearance.zsh} (100%) diff --git a/lib/appearance.zsh b/lib/theme-and-appearance.zsh similarity index 100% rename from lib/appearance.zsh rename to lib/theme-and-appearance.zsh From 41cca0586154c3a1c00b4dfdcf04ddf5171c8d22 Mon Sep 17 00:00:00 2001 From: Julien Nicoulaud Date: Sat, 20 Nov 2010 18:07:45 +0100 Subject: [PATCH 2/3] Add my prompt theme --- themes/nicoulaj.zsh-theme | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 themes/nicoulaj.zsh-theme diff --git a/themes/nicoulaj.zsh-theme b/themes/nicoulaj.zsh-theme new file mode 100644 index 0000000..edcdb15 --- /dev/null +++ b/themes/nicoulaj.zsh-theme @@ -0,0 +1,43 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------ +# Prompt for the Zsh shell: +# * One line. +# * VCS info on the right prompt. +# * Only shows the path on the left prompt by default. +# * Crops the path to a defined length and only shows the path relative to +# the current VCS repository root. +# * Wears a different color wether the last command succeeded/failed. +# * Shows user@hostname if connected through SSH. +# * Shows if logged in as root or not. +# ------------------------------------------------------------------------------ + +# Customizable parameters. +PROMPT_PATH_MAX_LENGTH=30 +PROMPT_DEFAULT_END=❯ +PROMPT_ROOT_END=❯❯❯ +PROMPT_SUCCESS_COLOR=$FG[071] +PROMPT_FAILURE_COLOR=$FG[124] +PROMPT_VCS_INFO_COLOR=$FG[242] + +# Set required options. +setopt promptsubst + +# Load required modules. +autoload -U add-zsh-hook +autoload -Uz vcs_info + +# Add hook for calling vcs_info before each command. +add-zsh-hook precmd vcs_info + +# Set vcs_info parameters. +zstyle ':vcs_info:*' enable hg bzr git +zstyle ':vcs_info:*:*' check-for-changes true # Can be slow on big repos. +zstyle ':vcs_info:*:*' unstagedstr '!' +zstyle ':vcs_info:*:*' stagedstr '+' +zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)" +zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c" +zstyle ':vcs_info:*:*' nvcsformats "%$PROMPT_PATH_MAX_LENGTH<..<%~%<<" "" + +# Define prompts. +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]%} " +RPROMPT="%{$PROMPT_VCS_INFO_COLOR%}"'$vcs_info_msg_1_'"%{$FX[reset]%}" From fc03db4e65d7bbfe5d0d7c23f586dd435025c23c Mon Sep 17 00:00:00 2001 From: Julien Nicoulaud Date: Sat, 20 Nov 2010 20:12:19 +0100 Subject: [PATCH 3/3] Avoid duplicate path cropping --- themes/nicoulaj.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/nicoulaj.zsh-theme b/themes/nicoulaj.zsh-theme index edcdb15..333aa5e 100644 --- a/themes/nicoulaj.zsh-theme +++ b/themes/nicoulaj.zsh-theme @@ -36,7 +36,7 @@ zstyle ':vcs_info:*:*' unstagedstr '!' zstyle ':vcs_info:*:*' stagedstr '+' zstyle ':vcs_info:*:*' actionformats "%S" "%r/%s/%b %u%c (%a)" zstyle ':vcs_info:*:*' formats "%S" "%r/%s/%b %u%c" -zstyle ':vcs_info:*:*' nvcsformats "%$PROMPT_PATH_MAX_LENGTH<..<%~%<<" "" +zstyle ':vcs_info:*:*' nvcsformats "%~" "" # Define prompts. 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]%} "