Fixed vim and zsh
This commit is contained in:
117
zsh/modules/prompt/themes/eriner.zsh-theme
Normal file
117
zsh/modules/prompt/themes/eriner.zsh-theme
Normal file
@ -0,0 +1,117 @@
|
||||
# vim:ts=2 sw=2 sts=2 ft=zsh
|
||||
#
|
||||
# Eriner's Theme - fork of agnoster
|
||||
# A Powerline-inspired theme for ZSH
|
||||
#
|
||||
# In order for this theme to render correctly, you will need a font with
|
||||
# powerline symbols. A simple way to add the powerline symbols is to follow the
|
||||
# instructions here:
|
||||
# https://simplyian.com/2014/03/28/using-powerline-symbols-with-your-current-font/
|
||||
#
|
||||
# The aim of this theme is to only show you *relevant* information. Like most
|
||||
# prompts, it will only show git information when in a git working directory.
|
||||
# However, it goes a step further: everything from the current user and
|
||||
# hostname to whether the last call exited with an error to whether background
|
||||
# jobs are running in this shell will all be displayed automatically when
|
||||
# appropriate.
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
### Segment drawing
|
||||
# Utility functions to make it easy and re-usable to draw segmented prompts.
|
||||
|
||||
local prompt_eriner_bg
|
||||
|
||||
# Begin a segment. Takes two arguments, background color and contents of the
|
||||
# new segment.
|
||||
prompt_eriner_segment() {
|
||||
print -n "%K{$1}"
|
||||
if [[ -n ${prompt_eriner_bg} ]]; then
|
||||
print -n "%F{${prompt_eriner_bg}}"
|
||||
fi
|
||||
print -n "$2"
|
||||
prompt_eriner_bg=$1
|
||||
}
|
||||
|
||||
# End the prompt, closing last segment.
|
||||
prompt_eriner_end() {
|
||||
print -n "%k%F{${prompt_eriner_bg}}%f "
|
||||
}
|
||||
|
||||
### Prompt components
|
||||
# Each component will draw itself, or hide itself if no information needs to be
|
||||
# shown.
|
||||
|
||||
# Status: Was there an error? Am I root? Are there background jobs? Who and
|
||||
# where am I (user@hostname)?
|
||||
prompt_eriner_status() {
|
||||
local segment=''
|
||||
(( ${RETVAL} )) && segment+=' %F{red}✘'
|
||||
(( ${UID} == 0 )) && segment+=' %F{yellow}⚡'
|
||||
(( $(jobs -l | wc -l) > 0 )) && segment+=' %F{cyan}⚙'
|
||||
if [[ ${USER} != ${DEFAULT_USER} || -n ${SSH_CLIENT} ]]; then
|
||||
segment+=' %F{%(!.yellow.default)}${USER}@%m'
|
||||
fi
|
||||
if [[ -n ${segment} ]]; then
|
||||
prompt_eriner_segment black "${segment} "
|
||||
fi
|
||||
}
|
||||
|
||||
# Ranger: <https://github.com/ranger/ranger>, which can spawn a shell under its
|
||||
# own process.
|
||||
prompt_eriner_ranger() {
|
||||
if (( ${RANGER_LEVEL} )); then
|
||||
prompt_eriner_segment blue ' %F{black}r '
|
||||
fi
|
||||
}
|
||||
|
||||
# Pwd: current working directory.
|
||||
prompt_eriner_pwd() {
|
||||
prompt_eriner_segment cyan " %F{black}$(short_pwd) "
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status.
|
||||
prompt_eriner_git() {
|
||||
if [[ -n ${git_info} ]]; then
|
||||
local indicator
|
||||
[[ ${git_info[color]} == yellow ]] && indicator='± '
|
||||
prompt_eriner_segment ${git_info[color]} " %F{black}${(e)git_info[prompt]} ${indicator}"
|
||||
fi
|
||||
}
|
||||
|
||||
### Main prompt
|
||||
prompt_eriner_main() {
|
||||
RETVAL=$?
|
||||
prompt_eriner_status
|
||||
prompt_eriner_ranger
|
||||
prompt_eriner_pwd
|
||||
prompt_eriner_git
|
||||
prompt_eriner_end
|
||||
}
|
||||
|
||||
prompt_eriner_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_eriner_setup() {
|
||||
autoload -Uz colors && colors
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
add-zsh-hook precmd prompt_eriner_precmd
|
||||
|
||||
zstyle ':zim:git-info:branch' format ' %b'
|
||||
zstyle ':zim:git-info:commit' format '➦ %c'
|
||||
zstyle ':zim:git-info:action' format ' (%s)'
|
||||
zstyle ':zim:git-info:clean' format 'green'
|
||||
zstyle ':zim:git-info:dirty' format 'yellow'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '%b%c%s' \
|
||||
'color' '%C%D'
|
||||
|
||||
PROMPT='${(e)$(prompt_eriner_main)}'
|
||||
RPROMPT=''
|
||||
}
|
||||
|
||||
prompt_eriner_setup "$@"
|
44
zsh/modules/prompt/themes/gitster.zsh-theme
Normal file
44
zsh/modules/prompt/themes/gitster.zsh-theme
Normal file
@ -0,0 +1,44 @@
|
||||
#
|
||||
# Gitster theme
|
||||
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_gitster_status() {
|
||||
print -n '%(?:%F{green}➜:%F{red}➜) '
|
||||
}
|
||||
|
||||
prompt_gitster_pwd() {
|
||||
prompt_short_dir=$(short_pwd)
|
||||
git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/}
|
||||
print -n "%F{white}${prompt_short_dir}"
|
||||
}
|
||||
|
||||
prompt_gitster_git() {
|
||||
[[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_gitster_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_gitster_setup() {
|
||||
autoload -Uz colors && colors
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
add-zsh-hook precmd prompt_gitster_precmd
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:clean' format '%F{green}✓'
|
||||
zstyle ':zim:git-info:dirty' format '%F{yellow}✗'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' ' %F{cyan}%b%c %C%D'
|
||||
|
||||
PROMPT='$(prompt_gitster_status)$(prompt_gitster_pwd)$(prompt_gitster_git)%f '
|
||||
RPROMPT=''
|
||||
}
|
||||
|
||||
prompt_gitster_setup "$@"
|
73
zsh/modules/prompt/themes/magicmace.zsh-theme
Normal file
73
zsh/modules/prompt/themes/magicmace.zsh-theme
Normal file
@ -0,0 +1,73 @@
|
||||
#
|
||||
# magicmace theme
|
||||
# Ideas and code taken from:
|
||||
# xero's zsh prompt <http://code.xero.nu/dotfiles>
|
||||
# eriner's eriner prompt <https://github.com/Eriner/zim/blob/master/modules/prompt/themes/eriner.zsh-theme>
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
# Global variables
|
||||
function {
|
||||
COLOR_ROOT="%F{red}"
|
||||
COLOR_USER="%F{cyan}"
|
||||
COLOR_NORMAL="%F{white}"
|
||||
COLOR_ERROR="%F{red}"
|
||||
|
||||
if (( ${EUID} )); then
|
||||
COLOR_USER_LEVEL=${COLOR_USER}
|
||||
else
|
||||
COLOR_USER_LEVEL=${COLOR_ROOT}
|
||||
fi
|
||||
}
|
||||
|
||||
# Status:
|
||||
# - was there an error?
|
||||
# - are there background jobs?
|
||||
# - are we in a ranger session?
|
||||
prompt_magicmace_status() {
|
||||
local symbols=""
|
||||
|
||||
(( ${RETVAL} )) && symbols+="${COLOR_ERROR}${RETVAL}${COLOR_NORMAL}" # $? for error.
|
||||
(( $(jobs -l | wc -l) > 0 )) && symbols+='b' # 'b' for background.
|
||||
(( ${RANGER_LEVEL} )) && symbols+='r' # 'r' for... you guessed it!
|
||||
|
||||
[[ -n ${symbols} ]] && print -n "─${COLOR_NORMAL}${symbols}${COLOR_USER_LEVEL}─"
|
||||
}
|
||||
|
||||
prompt_magicmace_git() {
|
||||
[[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_magicmace_precmd() {
|
||||
# While it would be apt to have this as a local variable in prompt_status(),
|
||||
# $? (returned value) and ${(%):-%?} ("The return status of the last command
|
||||
# executed just before the prompt") both change before executing the function.
|
||||
# Is this perhaps because prompt_status _is_ here?
|
||||
# We could also just set $? as an argument, and thus get our nifty local variable,
|
||||
# but that's stretching it, and makes the code harder to read.
|
||||
RETVAL=$?
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_magicmace_setup() {
|
||||
autoload -Uz colors && colors
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
add-zsh-hook precmd prompt_magicmace_precmd
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c...'
|
||||
zstyle ':zim:git-info:dirty' format '*'
|
||||
zstyle ':zim:git-info:ahead' format '↑'
|
||||
zstyle ':zim:git-info:behind' format '↓'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '─[${COLOR_NORMAL}%b%c%D%A%B${COLOR_USER_LEVEL}]'
|
||||
|
||||
# Call git directly, ignoring aliases under the same name.
|
||||
PROMPT='${COLOR_USER_LEVEL}$(prompt_magicmace_status)[${COLOR_NORMAL}$(short_pwd)${COLOR_USER_LEVEL}]$(prompt_magicmace_git)── ─%f '
|
||||
RPROMPT=''
|
||||
}
|
||||
|
||||
prompt_magicmace_setup "$@"
|
98
zsh/modules/prompt/themes/minimal.zsh-theme
Normal file
98
zsh/modules/prompt/themes/minimal.zsh-theme
Normal file
@ -0,0 +1,98 @@
|
||||
#
|
||||
# Minimal theme
|
||||
# https://github.com/S1cK94/minimal
|
||||
#
|
||||
|
||||
minimal_user() {
|
||||
print "%(!.$on_color.$off_color)$prompt_char%f"
|
||||
}
|
||||
|
||||
minimal_jobs() {
|
||||
print "%(1j.$on_color.$off_color)$prompt_char%f"
|
||||
}
|
||||
|
||||
minimal_vimode(){
|
||||
local ret=""
|
||||
|
||||
case $KEYMAP in
|
||||
main|viins)
|
||||
ret+="$on_color"
|
||||
;;
|
||||
vicmd)
|
||||
ret+="$off_color"
|
||||
;;
|
||||
esac
|
||||
|
||||
ret+="$prompt_char%f"
|
||||
|
||||
print "$ret"
|
||||
}
|
||||
|
||||
minimal_status() {
|
||||
print "%(0?.$on_color.$err_color)$prompt_char%f"
|
||||
}
|
||||
|
||||
minimal_path() {
|
||||
local path_color="%F{244}"
|
||||
local rsc="%f"
|
||||
local sep="$rsc/$path_color"
|
||||
|
||||
print "$path_color$(sed s_/_${sep}_g <<< $(short_pwd))$rsc"
|
||||
}
|
||||
|
||||
git_branch_name() {
|
||||
local branch_name="$(command git rev-parse --abbrev-ref HEAD 2> /dev/null)"
|
||||
[[ -n $branch_name ]] && print "$branch_name"
|
||||
}
|
||||
|
||||
git_repo_status(){
|
||||
local rs="$(command git status --porcelain -b)"
|
||||
|
||||
if $(print "$rs" | grep -v '^##' &> /dev/null); then # is dirty
|
||||
print "%F{red}"
|
||||
elif $(print "$rs" | grep '^## .*diverged' &> /dev/null); then # has diverged
|
||||
print "%F{red}"
|
||||
elif $(print "$rs" | grep '^## .*behind' &> /dev/null); then # is behind
|
||||
print "%F{11}"
|
||||
elif $(print "$rs" | grep '^## .*ahead' &> /dev/null); then # is ahead
|
||||
print "%f"
|
||||
else # is clean
|
||||
print "%F{green}"
|
||||
fi
|
||||
}
|
||||
|
||||
minimal_git() {
|
||||
local bname=$(git_branch_name)
|
||||
if [[ -n ${bname} ]]; then
|
||||
local infos="$(git_repo_status)${bname}%f"
|
||||
print " $infos"
|
||||
fi
|
||||
}
|
||||
|
||||
function zle-line-init zle-line-finish zle-keymap-select {
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
}
|
||||
|
||||
prompt_minimal_precmd() {
|
||||
zle -N zle-line-init
|
||||
zle -N zle-keymap-select
|
||||
zle -N zle-line-finish
|
||||
|
||||
PROMPT='$(minimal_user)$(minimal_jobs)$(minimal_vimode)$(minimal_status) '
|
||||
RPROMPT='$(minimal_path)$(minimal_git)'
|
||||
}
|
||||
|
||||
prompt_minimal_setup() {
|
||||
prompt_char="❯"
|
||||
on_color="%F{green}"
|
||||
off_color="%f"
|
||||
err_color="%F{red}"
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
add-zsh-hook precmd prompt_minimal_precmd
|
||||
prompt_opts=(cr subst percent)
|
||||
}
|
||||
|
||||
prompt_minimal_setup "$@"
|
102
zsh/modules/prompt/themes/steeef.zsh-theme
Normal file
102
zsh/modules/prompt/themes/steeef.zsh-theme
Normal file
@ -0,0 +1,102 @@
|
||||
# prompt style and colors based on Steve Losh's Prose theme:
|
||||
# http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
|
||||
#
|
||||
# vcs_info modifications from Bart Trojanowski's zsh prompt:
|
||||
# http://www.jukie.net/bart/blog/pimping-out-zsh-prompt
|
||||
#
|
||||
# git untracked files modification from Brian Carper:
|
||||
# http://briancarper.net/blog/570/git-info-in-your-zsh-prompt
|
||||
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
virtualenv_info() {
|
||||
[ ${VIRTUAL_ENV} ] && print '('${fg[blue]}${VIRTUAL_ENV:t}%{${reset_color}%}') '
|
||||
}
|
||||
|
||||
steeef_preexec() {
|
||||
case "$(history $HISTCMD)" in
|
||||
*git*)PR_GIT_UPDATE=1
|
||||
;;
|
||||
*svn*)PR_GIT_UPDATE=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
steeef_chpwd() {
|
||||
PR_GIT_UPDATE=1
|
||||
}
|
||||
|
||||
prompt_steeef_precmd() {
|
||||
if [[ -n "$PR_GIT_UPDATE" ]] ; then
|
||||
# check for untracked files or updated submodules, since vcs_info doesn't
|
||||
if git ls-files --other --exclude-standard 2> /dev/null | grep -q "."; then
|
||||
PR_GIT_UPDATE=1
|
||||
FMT_BRANCH="(%{$turquoise%}%b%u%c%{$hotpink%}●${PR_RST})"
|
||||
else
|
||||
FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
|
||||
fi
|
||||
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH} "
|
||||
|
||||
vcs_info 'prompt'
|
||||
fi
|
||||
|
||||
PROMPT='
|
||||
%{$purple%}%n${${reset_color}%} at %{$orange%}%m${${reset_color}%} in %{$limegreen%}%~${${reset_color}%} $vcs_info_msg_0_$(virtualenv_info)%{${reset_color}%}
|
||||
%(!.#.$) '
|
||||
}
|
||||
|
||||
prompt_steeef_setup() {
|
||||
#use extended color pallete if available
|
||||
if [[ ${TERM} == *256* || ${TERM} == *rxvt* ]]; then
|
||||
turquoise="%F{81}"
|
||||
orange="%F{166}"
|
||||
purple="%F{135}"
|
||||
hotpink="%F{161}"
|
||||
limegreen="%F{118}"
|
||||
else
|
||||
turquoise="%F{cyan}"
|
||||
orange="%F{yellow}"
|
||||
purple="%F{magenta}"
|
||||
hotpink="%F{red}"
|
||||
limegreen="%F{green}"
|
||||
fi
|
||||
|
||||
# enable VCS systems you use
|
||||
zstyle ':vcs_info:*' enable git 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
|
||||
|
||||
# set 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
|
||||
PR_RST="%f"
|
||||
FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
|
||||
FMT_ACTION="(%{$limegreen%}%a${PR_RST})"
|
||||
FMT_UNSTAGED="%{$orange%}●"
|
||||
FMT_STAGED="%{$limegreen%}●"
|
||||
|
||||
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 ""
|
||||
|
||||
PR_GIT_UPDATE=1
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
autoload -Uz colors && colors
|
||||
|
||||
add-zsh-hook preexec steeef_preexec
|
||||
add-zsh-hook chpwd steeef_chpwd
|
||||
add-zsh-hook precmd prompt_steeef_precmd
|
||||
prompt_opts=(cr subst percent)
|
||||
}
|
||||
|
||||
prompt_steeef_setup "$@"
|
Reference in New Issue
Block a user