mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 19:31:43 +00:00
43
modules/prompt/functions/prompt_minimal_setup
Normal file
43
modules/prompt/functions/prompt_minimal_setup
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# A monochrome theme that displays basic information.
|
||||
#
|
||||
# Authors:
|
||||
# Brian Tse <briankftse@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function +vi-git-status() {
|
||||
# Untracked files.
|
||||
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
||||
hook_com[unstaged]='%F{red}●%f'
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_minimal_precmd {
|
||||
vcs_info
|
||||
}
|
||||
|
||||
function prompt_minimal_setup {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
add-zsh-hook precmd prompt_minimal_precmd
|
||||
|
||||
zstyle ':vcs_info:*' enable bzr git hg svn
|
||||
zstyle ':vcs_info:*' check-for-changes true
|
||||
zstyle ':vcs_info:*' stagedstr '%F{green}●%f'
|
||||
zstyle ':vcs_info:*' unstagedstr '%F{yellow}●%f'
|
||||
zstyle ':vcs_info:*' formats ' - [%b%c%u]'
|
||||
zstyle ':vcs_info:*' actionformats " - [%b%c%u|%F{cyan}%a%f]"
|
||||
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b|%F{cyan}%r%f'
|
||||
zstyle ':vcs_info:git*+set-message:*' hooks git-status
|
||||
|
||||
PROMPT='%2~${vcs_info_msg_0_} » '
|
||||
}
|
||||
|
||||
prompt_minimal_setup "$@"
|
||||
|
58
modules/prompt/functions/prompt_nicoulaj_setup
Normal file
58
modules/prompt/functions/prompt_nicoulaj_setup
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
# 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
|
||||
# the current VCS repository root.
|
||||
# - 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.
|
||||
#
|
||||
|
||||
function prompt_nicoulaj_precmd {
|
||||
vcs_info
|
||||
}
|
||||
|
||||
function prompt_nicoulaj_setup {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
# Load required modules.
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
# Add hook for calling vcs_info before each command.
|
||||
add-zsh-hook precmd prompt_nicoulaj_precmd
|
||||
|
||||
# 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
|
||||
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 "%~" ""
|
||||
|
||||
# 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 "$@"
|
||||
|
52
modules/prompt/functions/prompt_sorin_setup
Normal file
52
modules/prompt/functions/prompt_sorin_setup
Normal file
@ -0,0 +1,52 @@
|
||||
#
|
||||
# A simple theme that only shows relevant information.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
# Screenshots:
|
||||
# http://i.imgur.com/aipDQ.png
|
||||
#
|
||||
|
||||
function prompt_sorin_precmd {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
|
||||
if (( $+functions[git-info] )); then
|
||||
git-info
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_sorin_setup {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd prompt_sorin_precmd
|
||||
|
||||
zstyle ':omz:module:editor' completing '%B%F{red}...%f%b'
|
||||
zstyle ':omz:prompt:vi' insert ''
|
||||
zstyle ':omz:prompt:vi' command ' %F{yellow}❮%f%B%F{red}❮%f%b%F{red}❮%f'
|
||||
zstyle ':omz:module:git:prompt' action ':%%B%F{yellow}%s%f%%b'
|
||||
zstyle ':omz:module:git:prompt' added ' %%B%F{green}✚%f%%b'
|
||||
zstyle ':omz:module:git:prompt' ahead ' %%B%F{yellow}⬆%f%%b'
|
||||
zstyle ':omz:module:git:prompt' behind ' %%B%F{yellow}⬇%f%%b'
|
||||
zstyle ':omz:module:git:prompt' branch ':%F{red}%b%f'
|
||||
zstyle ':omz:module:git:prompt' commit ':%F{green}%.7c%f'
|
||||
zstyle ':omz:module:git:prompt' deleted ' %%B%F{red}✖%f%%b'
|
||||
zstyle ':omz:module:git:prompt' modified ' %%B%F{blue}✱%f%%b'
|
||||
zstyle ':omz:module:git:prompt' position ':%F{green}%p%f'
|
||||
zstyle ':omz:module:git:prompt' renamed ' %%B%F{magenta}➜%f%%b'
|
||||
zstyle ':omz:module:git:prompt' stashed ' %%B%F{cyan}✭%f%%b'
|
||||
zstyle ':omz:module:git:prompt' unmerged ' %%B%F{yellow}═%f%%b'
|
||||
zstyle ':omz:module:git:prompt' untracked ' %%B%F{white}◼%f%%b'
|
||||
zstyle ':omz:module:git:prompt' prompt ' %F{blue}git%f$(coalesce "%b" "%p" "%c")%s'
|
||||
zstyle ':omz:module:git:prompt' rprompt '%A%B%S%a%d%m%r%U%u'
|
||||
|
||||
PROMPT='%F{cyan}%1~%f${(e)git_prompt_info} %(!.%B%F{red}#%f%b.%B%F{green}❯%f%b) '
|
||||
RPROMPT='${vi_prompt_info}%(?:: %F{red}⏎%f)${VIM:+" %B%F{green}V%f%b"}${git_rprompt_info}'
|
||||
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
||||
}
|
||||
|
||||
prompt_sorin_setup "$@"
|
113
modules/prompt/functions/prompt_steeef_setup
Normal file
113
modules/prompt/functions/prompt_steeef_setup
Normal file
@ -0,0 +1,113 @@
|
||||
#
|
||||
# A theme based on Steve Losh's prompt with VCS_INFO integration.
|
||||
#
|
||||
# Authors:
|
||||
# Steve Losh <steve@stevelosh.com>
|
||||
# Bart Trojanowski <bart@jukie.net>
|
||||
# Brian Carper <brian@carper.ca>
|
||||
# steeef <steeef@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function virtualenv_info {
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
print "(${VIRTUAL_ENV:t}) "
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_steeef_precmd {
|
||||
if [[ -n "$__PROMPT_STEEEF_VCS_UPDATE" ]] ; then
|
||||
# Check for untracked files or updated submodules since vcs_info doesn't.
|
||||
if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
||||
__PROMPT_STEEEF_VCS_UPDATE=1
|
||||
fmt_branch="(${__PROMPT_STEEEF_COLORS[1]}%b%f%u%c${__PROMPT_STEEEF_COLORS[4]}●%f)"
|
||||
else
|
||||
fmt_branch="(${__PROMPT_STEEEF_COLORS[1]}%b%f%u%c)"
|
||||
fi
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${fmt_branch}"
|
||||
|
||||
vcs_info 'prompt'
|
||||
__PROMPT_STEEEF_VCS_UPDATE=''
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_steeef_preexec {
|
||||
case "$(history $HISTCMD)" in
|
||||
(*git*)
|
||||
__PROMPT_STEEEF_VCS_UPDATE=1
|
||||
;;
|
||||
(*svn*)
|
||||
__PROMPT_STEEEF_VCS_UPDATE=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function prompt_steeef_chpwd {
|
||||
__PROMPT_STEEEF_VCS_UPDATE=1
|
||||
}
|
||||
|
||||
function prompt_steeef_setup {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
add-zsh-hook precmd prompt_steeef_precmd
|
||||
add-zsh-hook preexec prompt_steeef_preexec
|
||||
add-zsh-hook chpwd prompt_steeef_chpwd
|
||||
|
||||
__PROMPT_STEEEF_VCS_UPDATE=1
|
||||
|
||||
# Use extended color pallete if available.
|
||||
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
|
||||
__PROMPT_STEEEF_COLORS=(
|
||||
"%F{81}" # turquoise
|
||||
"%F{166}" # orange
|
||||
"%F{135}" # purple
|
||||
"%F{161}" # hotpink
|
||||
"%F{118}" # limegreen
|
||||
)
|
||||
else
|
||||
__PROMPT_STEEEF_COLORS=(
|
||||
"%F{cyan}"
|
||||
"%F{yellow}"
|
||||
"%F{magenta}"
|
||||
"%F{red}"
|
||||
"%F{green}"
|
||||
)
|
||||
fi
|
||||
|
||||
# Enable VCS systems you use.
|
||||
zstyle ':vcs_info:*' enable bzr git hg svn
|
||||
|
||||
# check-for-changes can be really slow.
|
||||
# You should disable it if you work with large repositories.
|
||||
zstyle ':vcs_info:*:prompt:*' check-for-changes true
|
||||
|
||||
# Formats:
|
||||
# %b - branchname
|
||||
# %u - unstagedstr (see below)
|
||||
# %c - stagedstr (see below)
|
||||
# %a - action (e.g. rebase-i)
|
||||
# %R - repository path
|
||||
# %S - path in the repository
|
||||
local fmt_branch="(${__PROMPT_STEEEF_COLORS[1]}%b%f%u%c)"
|
||||
local fmt_action="(${__PROMPT_STEEEF_COLORS[5]}%a%f)"
|
||||
local fmt_unstaged="${__PROMPT_STEEEF_COLORS[2]}●%f"
|
||||
local fmt_staged="${__PROMPT_STEEEF_COLORS[5]}●%f"
|
||||
|
||||
zstyle ':vcs_info:*:prompt:*' unstagedstr "${fmt_unstaged}"
|
||||
zstyle ':vcs_info:*:prompt:*' stagedstr "${fmt_staged}"
|
||||
zstyle ':vcs_info:*:prompt:*' actionformats "${fmt_branch}${fmt_action}"
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${fmt_branch}"
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
||||
|
||||
PROMPT="
|
||||
${__PROMPT_STEEEF_COLORS[3]}%n%f at ${__PROMPT_STEEEF_COLORS[2]}%m%f in ${__PROMPT_STEEEF_COLORS[5]}%~%f "'${vcs_info_msg_0_}'"
|
||||
"'$(virtualenv_info)'"$ "
|
||||
}
|
||||
|
||||
prompt_steeef_setup "$@"
|
||||
|
19
modules/prompt/init.zsh
Normal file
19
modules/prompt/init.zsh
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Loads prompt themes.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Load and run the prompt theming system.
|
||||
autoload -Uz promptinit && promptinit
|
||||
|
||||
# Load the prompt theme.
|
||||
zstyle -a ':omz:module:prompt' theme 'prompt_argv'
|
||||
if (( $#prompt_argv > 0 )); then
|
||||
prompt "$prompt_argv[@]"
|
||||
else
|
||||
prompt 'off'
|
||||
fi
|
||||
unset prompt_argv
|
||||
|
Reference in New Issue
Block a user