diff options
author | Oliver Kiddle <opk@users.sourceforge.net> | 2001-11-02 12:35:32 +0000 |
---|---|---|
committer | Oliver Kiddle <opk@users.sourceforge.net> | 2001-11-02 12:35:32 +0000 |
commit | 19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4 (patch) | |
tree | 3b66e84c8560e38fe7d13c2fb22b73decc43ded5 /Functions | |
parent | f3f81f0837e9c10ec9fd0808e8640ab8a23b7ba8 (diff) | |
download | zsh-19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4.tar.gz zsh-19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4.tar.xz zsh-19d2273cb7bdde0b13a8858ec8c4f264a2bb11b4.zip |
16198: add %j prompt expansion and j test character for no. of jobs in prompt
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/Prompts/prompt_oliver_setup | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/Functions/Prompts/prompt_oliver_setup b/Functions/Prompts/prompt_oliver_setup index 1f4e598fc..c4a28b705 100644 --- a/Functions/Prompts/prompt_oliver_setup +++ b/Functions/Prompts/prompt_oliver_setup @@ -1,35 +1,41 @@ # oliver prompt theme prompt_oliver_help() { - cat - <<ENDHELP + cat <<'ENDHELP' With this prompt theme, the prompt contains the current directory, -history number and the previous command\'s exit code (if non-zero) -and a final character which depends on priviledges. +history number, number of jobs (if non-zero) and the previous +command's exit code (if non-zero) and a final character which +depends on priviledges. The colour of the prompt depends on two associative arrays - -\$pcolour and $\tcolour. Each array is indexed by the name of the +$pcolour and $tcolour. Each array is indexed by the name of the local host. Alternatively, the colour can be set with parameters -to prompt. +to prompt. To specify colours, use English words like 'yellow', +optionally preceded by 'bold'. The hostname and username are also included unless they are in the -\$normal_hosts or \$normal_users array. +$normal_hosts or $normal_users array. ENDHELP } prompt_oliver_setup() { - prompt_opts=( percent set ) + prompt_opts=( cr subst percent ) + + [[ "${(t)pcolour}" != assoc* ]] && typeset -Ag pcolour + [[ "${(t)tcolour}" != assoc* ]] && typeset -Ag tcolour + local pcol=${1:-${pcolour[${HOST:=`hostname`}]:-yellow}} + local pcolr=$fg[${pcol#bold}] + [[ $pcol = bold* ]] && pcolr=$bold_color$pcolr + + local tcol=${2:-${tcolour[$HOST]:-white}} + local tcolr=$reset_color$fg[${tcol#bold}] + [[ $tcol = bold* ]] && tcolr=$tcolr$bold_color - local pcol=$'\e['${1:-${pcolour[${HOST:=`hostname`}]:-33}}m - local tcol=$'\e['${2:-${tcolour[$HOST]:-37}}m - local a host="%M:" user="%n " - for a in $normal_hosts; do - [[ $HOST == $a ]] && host="" - done - for a in root $normal_users; do - [[ ${USER:-`whoami`} == $a ]] && user="" - done + local a host="%m:" user="%n " + [[ $HOST == (${(j(|))~normal_hosts}) ]] && host="" + [[ ${USER:-`whoami`} == (root|${(j(|))~normal_users}) ]] && user="" - PS1="%{$pcol%}$user$host%~ [%h%0(?..:%?)]%# %{$tcol%}" + PS1="%{$pcolr%}$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline. )[%h%1(j.%%%j.)%0(?..:%?)]%# %{$tcolr%}" } prompt_oliver_setup "$@" |