From 7f6f8737aedd6fdf41ca69048a3267dc969f4a6e Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Fri, 12 Jan 2018 16:03:42 -0500 Subject: [PATCH] [prompt] steef: Update it to be customizable and to have a help and a preview too. Inspired by #192, and by having (few but) good prompt themes to serve as starting points for the users to customize or implement their own. --- modules/prompt/themes/steeef.zsh-theme | 111 ++++++++++++++++++------- 1 file changed, 81 insertions(+), 30 deletions(-) diff --git a/modules/prompt/themes/steeef.zsh-theme b/modules/prompt/themes/steeef.zsh-theme index ad33d97..be77a16 100644 --- a/modules/prompt/themes/steeef.zsh-theme +++ b/modules/prompt/themes/steeef.zsh-theme @@ -1,8 +1,39 @@ -# prompt style and colors based on Steve Losh's Prose theme: -# http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme +# vim:et sts=2 sw=2 ft=zsh +# +# A customizable version of the steeef theme from +# https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/steeef.zsh-theme # # Requires the `git-info` zmodule to be included in the .zimrc file. +prompt_steeef_help () { + cat <= 256 )); then + col_user="%F{${1:-135}}" + col_host="%F{${2:-166}}" + col_pwd="%F{${3:-118}}" + col_brnch="%F{${4:-81}}" + col_unidx="%F{${5:-166}}" + col_idx="%F{${7:-118}}" + col_untrk="%F{${9:-161}}" else - purple='%F{magenta}' - orange='%F{yellow}' - limegreen='%F{green}' - turquoise='%F{cyan}' - hotpink='%F{red}' + col_user="%F{${1:-magenta}}" + col_host="%F{${2:-yellow}}" + col_pwd="%F{${3:-green}}" + col_brnch="%F{${4:-cyan}}" + col_unidx="%F{${5:-yellow}}" + col_idx="%F{${7:-green}}" + col_untrk="%F{${9:-red}}" fi + local ind_unidx=${6:-●} + local ind_idx=${8:-●} + local ind_untrk=${10:-●} + local col_stash=${11:+%F{${11}}} + local ind_stash=${12} - autoload -Uz add-zsh-hook + autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_steeef_precmd autoload -Uz colors && colors prompt_opts=(cr percent sp subst) - add-zsh-hook precmd prompt_steeef_precmd - zstyle ':zim:git-info' verbose 'yes' zstyle ':zim:git-info:branch' format '%b' zstyle ':zim:git-info:commit' format '%c' - zstyle ':zim:git-info:action' format "(${limegreen}%s%f)" - zstyle ':zim:git-info:unindexed' format "${orange}●" - zstyle ':zim:git-info:indexed' format "${limegreen}●" - zstyle ':zim:git-info:untracked' format "${hotpink}●" + zstyle ':zim:git-info:action' format "(${col_idx}%s%f)" + zstyle ':zim:git-info:unindexed' format "${col_unidx}${ind_unidx}" + zstyle ':zim:git-info:indexed' format "${col_idx}${ind_idx}" + zstyle ':zim:git-info:untracked' format "${col_untrk}${ind_untrk}" + zstyle ':zim:git-info:stashed' format "${col_stash}${ind_stash}" zstyle ':zim:git-info:keys' format \ - 'prompt' "(${turquoise}%b%c%I%i%u%f)%s" + 'prompt' "(${col_brnch}%b%c%I%i%u%f%S%f)%s" - PROMPT=" -${purple}%n%f at ${orange}%m%f in ${limegreen}%~%f\$(prompt_steeef_git)\$(prompt_steeef_virtualenv) + PS1=" +${col_user}%n%f at ${col_host}%m%f in ${col_pwd}%~%f\$(prompt_steeef_git)\$(prompt_steeef_virtualenv) %(!.#.$) " - RPROMPT='' + RPS1='' } -prompt_steeef_setup "$@" +prompt_steeef_preview () { + if (( $# )); then + prompt_preview_theme steeef "${@}" + else + prompt_preview_theme steeef + print + prompt_preview_theme steeef magenta yellow green cyan magenta '!' green '+' red '?' yellow '$' + fi +} + +prompt_steeef_setup "${@}"