[prompt] add setup function to themes
proper setup and preview of themes with 'prompt' function closes #12, closes #15
This commit is contained in:
parent
5f68411637
commit
b46edd43a8
1
modules/prompt/functions/ext-liquidprompt
Symbolic link
1
modules/prompt/functions/ext-liquidprompt
Symbolic link
@ -0,0 +1 @@
|
||||
../external-themes/liquidprompt/liquidprompt
|
@ -1 +0,0 @@
|
||||
../external-themes/liquidprompt/liquidprompt
|
15
modules/prompt/functions/prompt_liquidprompt_setup
Normal file
15
modules/prompt/functions/prompt_liquidprompt_setup
Normal file
@ -0,0 +1,15 @@
|
||||
function prompt_liquidprompt_setup() {
|
||||
autoload -Uz ex-liquidprompt
|
||||
|
||||
ext-liquidprompt
|
||||
prompt_opts=(cr subst percent)
|
||||
}
|
||||
|
||||
function prompt_liquidprompt_preview() {
|
||||
_lp_set_prompt
|
||||
prompt_preview_theme liquidprompt
|
||||
}
|
||||
|
||||
prompt_liquidprompt_setup "$@"
|
||||
|
||||
# vim:filetype=zsh
|
@ -3,12 +3,11 @@
|
||||
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
|
||||
#
|
||||
|
||||
autoload -Uz colors && colors
|
||||
prompt_opts=( cr subst percent )
|
||||
function gst_get_status(){
|
||||
print "%(?:%F{10}➜ :%F{9}➜ %s)"
|
||||
}
|
||||
|
||||
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
|
||||
|
||||
function get_pwd(){
|
||||
function gst_get_pwd(){
|
||||
git_root=$PWD
|
||||
while [[ $git_root != / && ! -e $git_root/.git ]]; do
|
||||
git_root=$git_root:h
|
||||
@ -23,9 +22,20 @@ function get_pwd(){
|
||||
print $prompt_short_dir
|
||||
}
|
||||
|
||||
PROMPT='$ret_status %{$fg[white]%}$(get_pwd) $(git_prompt_info)%{$reset_color%}%{$reset_color%} '
|
||||
function prompt_gitster_precmd(){
|
||||
PROMPT='$(gst_get_status) %F{white}$(gst_get_pwd) $(git_prompt_info)%f '
|
||||
}
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[yellow]%}✗%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✓%{$reset_color%}"
|
||||
function prompt_gitster_setup(){
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%F{cyan}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %F{yellow}✗%f"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %F{green}✓%f"
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
add-zsh-hook precmd prompt_gitster_precmd
|
||||
prompt_opts=(cr subst percent)
|
||||
}
|
||||
|
||||
prompt_gitster_setup "$@"
|
||||
|
@ -3,26 +3,33 @@
|
||||
# https://github.com/S1cK94/minimal
|
||||
#
|
||||
|
||||
autoload -Uz colors && colors
|
||||
|
||||
prompt_opts=( cr subst percent )
|
||||
|
||||
PROMPT_CHAR="❯"
|
||||
|
||||
ON_COLOR="%{$fg[green]%}"
|
||||
OFF_COLOR="%{$reset_color%}"
|
||||
ERR_COLOR="%{$fg[red]%}"
|
||||
|
||||
function prompt_user() {
|
||||
echo "%(!.$ON_COLOR.$OFF_COLOR)$PROMPT_CHAR%{$reset_color%}"
|
||||
function minimal_user() {
|
||||
echo "%(!.$on_color.$off_color)$prompt_char%f"
|
||||
}
|
||||
|
||||
function prompt_jobs() {
|
||||
echo "%(1j.$ON_COLOR.$OFF_COLOR)$PROMPT_CHAR%{$reset_color%}"
|
||||
function minimal_jobs() {
|
||||
echo "%(1j.$on_color.$off_color)$prompt_char%f"
|
||||
}
|
||||
|
||||
function prompt_status() {
|
||||
echo "%(0?.$ON_COLOR.$ERR_COLOR)$PROMPT_CHAR%{$reset_color%}"
|
||||
function minimal_vimode(){
|
||||
local ret=""
|
||||
|
||||
case $KEYMAP in
|
||||
main|viins)
|
||||
ret+="$on_color"
|
||||
;;
|
||||
vicmd)
|
||||
ret+="$off_color"
|
||||
;;
|
||||
esac
|
||||
|
||||
ret+="$prompt_char%f"
|
||||
|
||||
echo "$ret"
|
||||
}
|
||||
|
||||
function minimal_status() {
|
||||
echo "%(0?.$on_color.$err_color)$prompt_char%f"
|
||||
}
|
||||
|
||||
function -prompt_ellipse(){
|
||||
@ -35,12 +42,12 @@ function -prompt_ellipse(){
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_path() {
|
||||
local path_color="%{[38;5;244m%}%}"
|
||||
local rsc="%{$reset_color%}"
|
||||
function minimal_path() {
|
||||
local path_color="%F{244}"
|
||||
local rsc="%f"
|
||||
local sep="$rsc/$path_color"
|
||||
|
||||
echo "$path_color$(print -P %2~ | sed s_/_${sep}_g)$rsc"
|
||||
echo "$path_color$(sed s_/_${sep}_g <<< $(short_pwd))$rsc"
|
||||
}
|
||||
|
||||
function git_branch_name() {
|
||||
@ -52,52 +59,50 @@ function git_repo_status(){
|
||||
local rs="$(git status --porcelain -b)"
|
||||
|
||||
if $(echo "$rs" | grep -v '^##' &> /dev/null); then # is dirty
|
||||
echo "%{$fg[red]%}"
|
||||
echo "%F{red}"
|
||||
elif $(echo "$rs" | grep '^## .*diverged' &> /dev/null); then # has diverged
|
||||
echo "%{$fg[red]%}"
|
||||
echo "%F{red}"
|
||||
elif $(echo "$rs" | grep '^## .*behind' &> /dev/null); then # is behind
|
||||
echo "%{[38;5;011m%}%}"
|
||||
echo "%F{11}"
|
||||
elif $(echo "$rs" | grep '^## .*ahead' &> /dev/null); then # is ahead
|
||||
echo "%{$reset_color%}"
|
||||
echo "%f"
|
||||
else # is clean
|
||||
echo "%{$fg[green]%}"
|
||||
echo "%F{green}"
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_git() {
|
||||
function minimal_git() {
|
||||
local bname=$(git_branch_name)
|
||||
if [[ -n $bname ]]; then
|
||||
local infos="$(git_repo_status)$bname%{$reset_color%}"
|
||||
local infos="$(git_repo_status)$bname%f"
|
||||
echo " $infos"
|
||||
fi
|
||||
}
|
||||
|
||||
function prompt_vimode(){
|
||||
local ret=""
|
||||
|
||||
case $KEYMAP in
|
||||
main|viins)
|
||||
ret+="$ON_COLOR"
|
||||
;;
|
||||
vicmd)
|
||||
ret+="$OFF_COLOR"
|
||||
;;
|
||||
esac
|
||||
|
||||
ret+="$PROMPT_CHAR%{$reset_color%}"
|
||||
|
||||
echo "$ret"
|
||||
}
|
||||
|
||||
function zle-line-init zle-line-finish zle-keymap-select {
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
}
|
||||
|
||||
function prompt_minimal_precmd() {
|
||||
zle -N zle-line-init
|
||||
zle -N zle-keymap-select
|
||||
zle -N zle-line-finish
|
||||
|
||||
PROMPT='$(prompt_user)$(prompt_jobs)$(prompt_vimode)$(prompt_status) '
|
||||
RPROMPT='$(prompt_path)$(prompt_git)'
|
||||
PROMPT='$(minimal_user)$(minimal_jobs)$(minimal_vimode)$(minimal_status) '
|
||||
RPROMPT='$(minimal_path)$(minimal_git)'
|
||||
}
|
||||
|
||||
function 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 "$@"
|
||||
|
@ -12,14 +12,43 @@ export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
function virtualenv_info {
|
||||
[ $VIRTUAL_ENV ] && print '('${fg[blue]}`basename $VIRTUAL_ENV`%{${reset_color}%}') '
|
||||
}
|
||||
|
||||
function steeef_preexec {
|
||||
case "$(history $HISTCMD)" in
|
||||
*git*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
*svn*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
prompt_opts=( cr subst percent )
|
||||
function steeef_chpwd {
|
||||
PR_GIT_UPDATE=1
|
||||
}
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
autoload -Uz colors && colors
|
||||
function 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'
|
||||
PR_GIT_UPDATE=
|
||||
fi
|
||||
|
||||
PROMPT='
|
||||
%{$purple%}%n${${reset_color}%} at %{$orange%}%m${${reset_color}%} in %{$limegreen%}%~${${reset_color}%} $vcs_info_msg_0_$(virtualenv_info)%{${reset_color}%}
|
||||
$ '
|
||||
}
|
||||
|
||||
function prompt_steeef_setup {
|
||||
#use extended color pallete if available
|
||||
if [[ ${TERM} == *256* || ${TERM} == *rxvt* ]]; then
|
||||
turquoise="%F{81}"
|
||||
@ -28,11 +57,11 @@ if [[ ${TERM} == *256* || ${TERM} == *rxvt* ]]; then
|
||||
hotpink="%F{161}"
|
||||
limegreen="%F{118}"
|
||||
else
|
||||
turquoise="$fg[cyan]"
|
||||
orange="$fg[yellow]"
|
||||
purple="$fg[magenta]"
|
||||
hotpink="$fg[red]"
|
||||
limegreen="$fg[green]"
|
||||
turquoise="%F{cyan}"
|
||||
orange="%F{yellow}"
|
||||
purple="%F{magenta}"
|
||||
hotpink="%F{red}"
|
||||
limegreen="%F{green}"
|
||||
fi
|
||||
|
||||
# enable VCS systems you use
|
||||
@ -49,7 +78,7 @@ zstyle ':vcs_info:*:prompt:*' check-for-changes true
|
||||
# %a - action (e.g. rebase-i)
|
||||
# %R - repository path
|
||||
# %S - path in the repository
|
||||
PR_RST="%{${reset_color}%}"
|
||||
PR_RST="%f"
|
||||
FMT_BRANCH="(%{$turquoise%}%b%u%c${PR_RST})"
|
||||
FMT_ACTION="(%{$limegreen%}%a${PR_RST})"
|
||||
FMT_UNSTAGED="%{$orange%}●"
|
||||
@ -61,41 +90,16 @@ 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
|
||||
|
||||
function steeef_preexec {
|
||||
case "$(history $HISTCMD)" in
|
||||
*git*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
*svn*)
|
||||
PR_GIT_UPDATE=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
add-zsh-hook preexec steeef_preexec
|
||||
|
||||
function steeef_chpwd {
|
||||
PR_GIT_UPDATE=1
|
||||
}
|
||||
add-zsh-hook chpwd steeef_chpwd
|
||||
|
||||
function 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'
|
||||
PR_GIT_UPDATE=
|
||||
fi
|
||||
add-zsh-hook precmd prompt_steeef_precmd
|
||||
prompt_opts=(cr subst percent)
|
||||
}
|
||||
add-zsh-hook precmd steeef_precmd
|
||||
|
||||
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 "$@"
|
||||
|
Reference in New Issue
Block a user