1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-19 21:44:11 +01:00
zsh/Functions/Prompts/prompt_oliver_setup

44 lines
1.4 KiB
Plaintext
Raw Normal View History

1999-10-19 21:57:39 +02:00
# oliver prompt theme
prompt_oliver_help() {
cat <<'ENDHELP'
1999-10-19 21:57:39 +02:00
With this prompt theme, the prompt contains the current directory,
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.
1999-10-19 21:57:39 +02:00
The colour of the prompt depends on two associative arrays -
$pcolour and $tcolour. Each array is indexed by the name of the
1999-10-19 21:57:39 +02:00
local host. Alternatively, the colour can be set with parameters
to prompt. To specify colours, use English words like 'yellow',
optionally preceded by 'bold'.
1999-10-19 21:57:39 +02:00
The hostname and username are also included unless they are in the
$normal_hosts or $normal_users array.
1999-10-19 21:57:39 +02:00
ENDHELP
}
prompt_oliver_setup() {
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
1999-10-19 21:57:39 +02:00
local a host="%m:" user="%n "
[[ $HOST == (${(j(|))~normal_hosts}) ]] && host=""
[[ ${USER:-`whoami`} == (root|${(j(|))~normal_users}) ]] && user=""
1999-10-19 21:57:39 +02:00
PS1="%{$pcolr%}$user$host%~%"'$((COLUMNS-12))'"(l.$prompt_newline. )[%h%1(j.%%%j.)%0(?..:%?)]%# %{$tcolr%}"
2002-01-31 16:30:41 +01:00
RPS2='<%^'
PS2=''
1999-10-19 21:57:39 +02:00
}
prompt_oliver_setup "$@"