2012-02-01 05:37:51 +01:00
|
|
|
|
#
|
|
|
|
|
# A simple theme that displays only relevant information.
|
|
|
|
|
#
|
|
|
|
|
# Authors:
|
|
|
|
|
# Julien Nicoulaud <julien.nicoulaud@gmail.com>
|
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
|
#
|
|
|
|
|
# Features:
|
|
|
|
|
# - One line.
|
|
|
|
|
# - VCS information in 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
|
2011-07-18 02:15:51 +02:00
|
|
|
|
# the current VCS repository root.
|
2012-02-01 05:37:51 +01:00
|
|
|
|
# - Uses a different color depending on if the last command succeeded/failed.
|
|
|
|
|
# - Shows user@hostname if connected through SSH.
|
|
|
|
|
# - Shows if logged in as root or not.
|
|
|
|
|
#
|
2012-08-06 22:53:03 +02:00
|
|
|
|
# Screenshots:
|
|
|
|
|
# http://i.imgur.com/Xe1bu.png
|
|
|
|
|
#
|
2011-07-18 02:15:51 +02:00
|
|
|
|
|
2012-03-23 19:57:51 +01:00
|
|
|
|
function prompt_nicoulaj_precmd {
|
2012-03-12 00:21:53 +01:00
|
|
|
|
vcs_info
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-23 19:57:51 +01:00
|
|
|
|
function prompt_nicoulaj_setup {
|
2011-10-11 04:16:12 +02:00
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
|
prompt_opts=(cr percent subst)
|
2011-07-18 02:15:51 +02:00
|
|
|
|
|
2012-08-06 22:52:38 +02:00
|
|
|
|
# Load required functions.
|
2011-07-18 02:15:51 +02:00
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
|
|
|
|
|
|
# Add hook for calling vcs_info before each command.
|
2012-03-12 00:21:53 +01:00
|
|
|
|
add-zsh-hook precmd prompt_nicoulaj_precmd
|
2011-07-18 02:15:51 +02:00
|
|
|
|
|
|
|
|
|
# Customizable parameters.
|
|
|
|
|
local max_path_chars=30
|
|
|
|
|
local user_char='❯'
|
|
|
|
|
local root_char='❯❯❯'
|
|
|
|
|
local success_color='%F{071}'
|
|
|
|
|
local failure_color='%F{124}'
|
|
|
|
|
local vcs_info_color='%F{242}'
|
|
|
|
|
|
|
|
|
|
# Set vcs_info parameters.
|
|
|
|
|
zstyle ':vcs_info:*' enable bzr git hg svn
|
2012-09-10 19:24:34 +02:00
|
|
|
|
zstyle ':vcs_info:*' check-for-changes true
|
|
|
|
|
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 "%~" ""
|
2011-07-18 02:15:51 +02:00
|
|
|
|
|
|
|
|
|
# Define prompts.
|
|
|
|
|
PROMPT="%(?.${success_color}.${failure_color})${SSH_TTY:+[%n@%m]}%B%${max_path_chars}<...<"'${vcs_info_msg_0_%%.}'"%<<%(!.${root_char}.${user_char})%b%f "
|
|
|
|
|
RPROMPT="${vcs_info_color}"'${vcs_info_msg_1_}'"%f"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prompt_nicoulaj_setup "$@"
|