diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-19 11:48:09 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-11-19 11:48:09 +0000 |
commit | 5efc7525eceb8d3b5fd5f6d51396e6d58d84fa88 (patch) | |
tree | fd2efc6cf4f8bdd5607d920a1dc85d98ca5d16c5 /Functions/Prompts/prompt_oliver_setup | |
parent | 8efd8205edc3e19f6f28129ca2aef01f54cbcbb0 (diff) | |
download | zsh-5efc7525eceb8d3b5fd5f6d51396e6d58d84fa88.tar.gz zsh-5efc7525eceb8d3b5fd5f6d51396e6d58d84fa88.tar.xz zsh-5efc7525eceb8d3b5fd5f6d51396e6d58d84fa88.zip |
manual/8684
Diffstat (limited to 'Functions/Prompts/prompt_oliver_setup')
-rw-r--r-- | Functions/Prompts/prompt_oliver_setup | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Functions/Prompts/prompt_oliver_setup b/Functions/Prompts/prompt_oliver_setup index a1bce3da2..1d32dd49d 100644 --- a/Functions/Prompts/prompt_oliver_setup +++ b/Functions/Prompts/prompt_oliver_setup @@ -9,7 +9,8 @@ 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 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. @@ -17,21 +18,23 @@ ENDHELP } prompt_oliver_setup() { - prompt_opts=( percent ) + prompt_opts=( cr subst percent ) [[ "${(t)pcolour}" != assoc* ]] && typeset -Ag pcolour [[ "${(t)tcolour}" != assoc* ]] && typeset -Ag tcolour - local pcol=$'\e['${1:-${pcolour[${HOST:=`hostname`}]:-33}}m - local tcol=$'\e['${2:-${tcolour[$HOST]:-37}}m + 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 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 + [[ $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%0(?..:%?)]%# %{$tcolr%}" } prompt_oliver_setup "$@" |