mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-23 16:40:24 +02:00
manual/8684
This commit is contained in:
parent
8efd8205ed
commit
5efc7525ec
6 changed files with 26 additions and 17 deletions
|
@ -4,7 +4,8 @@ prompt_off_setup () {
|
|||
PS1="%# "
|
||||
PS2="> "
|
||||
|
||||
precmd () { setopt promptsubst }
|
||||
prompt_opts=( cr percent )
|
||||
precmd () { }
|
||||
preexec () { }
|
||||
}
|
||||
|
||||
|
|
|
@ -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 "$@"
|
||||
|
|
|
@ -6,7 +6,8 @@ prompt_redhat_setup () {
|
|||
PS1="[%n@%m %1~]\\$ "
|
||||
PS2="> "
|
||||
|
||||
precmd () { setopt promptsubst }
|
||||
prompt_opts=( cr percent )
|
||||
precmd () { }
|
||||
preexec () { }
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ prompt_suse_setup () {
|
|||
PS1="%n@%m:%~/ > "
|
||||
PS2="> "
|
||||
|
||||
precmd () { setopt promptsubst }
|
||||
prompt_opts=( cr percent )
|
||||
precmd () { }
|
||||
preexec () { }
|
||||
}
|
||||
|
||||
|
|
|
@ -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 () { }
|
||||
}
|
||||
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue