diff options
-rw-r--r-- | Functions/Prompts/prompt_off_setup | 3 | ||||
-rw-r--r-- | Functions/Prompts/prompt_oliver_setup | 25 | ||||
-rw-r--r-- | Functions/Prompts/prompt_redhat_setup | 3 | ||||
-rw-r--r-- | Functions/Prompts/prompt_suse_setup | 3 | ||||
-rw-r--r-- | Functions/Prompts/prompt_zefram_setup | 3 | ||||
-rw-r--r-- | Functions/Prompts/promptinit | 6 |
6 files changed, 26 insertions, 17 deletions
diff --git a/Functions/Prompts/prompt_off_setup b/Functions/Prompts/prompt_off_setup index c5820007e..4eef43e13 100644 --- a/Functions/Prompts/prompt_off_setup +++ b/Functions/Prompts/prompt_off_setup @@ -4,7 +4,8 @@ prompt_off_setup () { PS1="%# " PS2="> " - precmd () { setopt promptsubst } + prompt_opts=( cr percent ) + precmd () { } preexec () { } } 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 "$@" diff --git a/Functions/Prompts/prompt_redhat_setup b/Functions/Prompts/prompt_redhat_setup index 876797899..58e6bd698 100644 --- a/Functions/Prompts/prompt_redhat_setup +++ b/Functions/Prompts/prompt_redhat_setup @@ -6,7 +6,8 @@ prompt_redhat_setup () { PS1="[%n@%m %1~]\\$ " PS2="> " - precmd () { setopt promptsubst } + prompt_opts=( cr percent ) + precmd () { } preexec () { } } diff --git a/Functions/Prompts/prompt_suse_setup b/Functions/Prompts/prompt_suse_setup index 64fa410dc..9b937be07 100644 --- a/Functions/Prompts/prompt_suse_setup +++ b/Functions/Prompts/prompt_suse_setup @@ -6,7 +6,8 @@ prompt_suse_setup () { PS1="%n@%m:%~/ > " PS2="> " - precmd () { setopt promptsubst } + prompt_opts=( cr percent ) + precmd () { } preexec () { } } diff --git a/Functions/Prompts/prompt_zefram_setup b/Functions/Prompts/prompt_zefram_setup index 3e6d34840..99585edec 100644 --- a/Functions/Prompts/prompt_zefram_setup +++ b/Functions/Prompts/prompt_zefram_setup @@ -10,7 +10,8 @@ function prompt_zefram_setup { PS1='[%(2L.%L/.)'$ZSH_VERSION']%(?..%B{%v}%b)%n%(2v.%B@%b.@)%m:%B%~%b%(!.#.>) ' PS2='%(4_:... :)%3_> ' - precmd () { prompt_zefram_precmd; setopt promptsubst } + prompt_opts=( cr subst percent ) + precmd () { prompt_zefram_precmd } preexec () { } } diff --git a/Functions/Prompts/promptinit b/Functions/Prompts/promptinit index cfab990df..faa73be21 100644 --- a/Functions/Prompts/promptinit +++ b/Functions/Prompts/promptinit @@ -8,12 +8,12 @@ prompt_themes=() typeset -gU prompt_themes -typeset -g prompt_theme +typeset -g prompt_theme >/dev/null promptinit () { emulate -L zsh setopt extendedglob - local ppath='' name + local ppath='' name theme # Autoload all prompt_*_setup functions in fpath for theme in $^fpath/prompt_*_setup(N); do @@ -170,6 +170,8 @@ prompt () { (( $#prompt_opts )) && setopt noprompt{bang,cr,percent,subst} prompt${^prompt_opts[@]} + + true } prompt_preview_theme () { |