Added my theme
This commit is contained in:
parent
2f4f11bd40
commit
f83f705205
1 changed files with 96 additions and 0 deletions
96
modules/prompt/functions/prompt_hapless_setup
Normal file
96
modules/prompt/functions/prompt_hapless_setup
Normal file
|
@ -0,0 +1,96 @@
|
|||
#
|
||||
# A compact and informative prompt theme
|
||||
# by haplesshero13 <haplesshero13@gmail.com>
|
||||
# Features VCS and RVM/rbenv info.
|
||||
#
|
||||
# The prompt borrows (steals) the fine work and ideas of
|
||||
# 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>
|
||||
#
|
||||
# Screenshot can be found at:
|
||||
# http://www.flickr.com/photos/79770035@N03/7867663652/
|
||||
#
|
||||
|
||||
function prompt_char {
|
||||
git branch >/dev/null 2>/dev/null && echo 'λ' && return
|
||||
hg root >/dev/null 2>/dev/null && echo '☿' && return
|
||||
echo '$'
|
||||
}
|
||||
|
||||
function rvm_info {
|
||||
if which rvm-prompt &> /dev/null; then
|
||||
echo "‹${_prompt_hapless_colors[5]}$(rvm-prompt i v g)%f›"
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
echo "‹${_prompt_hapless_colors[5]}$(rbenv version | sed -e "s/ (set.*$//")%f›"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_hapless_precmd {
|
||||
# Check for untracked files or updated submodules since vcs_info does not.
|
||||
if [[ (-n $(git ls-files --others --exclude-standard 2> /dev/null)) || (-n $(hg status -u 2> /dev/null)) ]]; then
|
||||
branch_format="(${_prompt_hapless_colors[1]}%b%f%u%c${_prompt_hapless_colors[4]}?%f)"
|
||||
else
|
||||
branch_format="(${_prompt_hapless_colors[1]}%b%f%u%c)"
|
||||
fi
|
||||
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
|
||||
|
||||
vcs_info 'prompt'
|
||||
}
|
||||
|
||||
function prompt_hapless_setup {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
# Load required functions.
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
# Add hook for calling vcs_info before each command.
|
||||
add-zsh-hook precmd prompt_hapless_precmd
|
||||
|
||||
_prompt_hapless_colors=(
|
||||
"%F{cyan}"
|
||||
"%F{yellow}"
|
||||
"%F{magenta}"
|
||||
"%F{red}"
|
||||
"%F{green}"
|
||||
)
|
||||
|
||||
# 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 branch_format="(${_prompt_hapless_colors[1]}%b%f%u%c)"
|
||||
local action_format="(${_prompt_hapless_colors[5]}%a%f)"
|
||||
local unstaged_format="${_prompt_hapless_colors[2]}!%f"
|
||||
local staged_format="${_prompt_hapless_colors[5]}+%f"
|
||||
local return_code='%(?..${_prompt_hapless_colors[4]}%? ↵%f)'
|
||||
|
||||
# Set vcs_info parameters.
|
||||
zstyle ':vcs_info:*' enable git hg
|
||||
zstyle ':vcs_info:*:prompt:*' check-for-changes true
|
||||
zstyle ':vcs_info:hg*:prompt:*' get-revision true
|
||||
zstyle ':vcs_info:hg*:prompt:*' hgrevformat ""
|
||||
zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}"
|
||||
zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}"
|
||||
zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}"
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
||||
|
||||
# Define prompts.
|
||||
PROMPT="${_prompt_hapless_colors[3]}%n%f@${_prompt_hapless_colors[2]}%m%f:${_prompt_hapless_colors[1]}%~%f"'$(prompt_char) '
|
||||
RPROMPT="${return_code} "'${vcs_info_msg_0_}$(rvm_info)'
|
||||
}
|
||||
|
||||
prompt_hapless_setup "$@"
|
||||
|
Loading…
Add table
Reference in a new issue