1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-05-21 23:46:03 +02:00

Initial revision

This commit is contained in:
Tanaka Akira 1999-10-04 22:57:19 +00:00
parent 298c35419d
commit d3170c8ee6
20 changed files with 679 additions and 0 deletions

7
Completion/User/_prompt Normal file
View File

@ -0,0 +1,7 @@
#compdef prompt
_arguments -s \
'-l[list themes]:*:' \
"-h[help]::prompt theme:($prompt_themes):*:" \
"-p[preview theme(s)]:*:prompt theme:($prompt_themes):*:" \
{-s'[set and save theme]','*'}":prompt themes:($prompt_themes):*:"

67
Functions/Misc/colors Normal file
View File

@ -0,0 +1,67 @@
# Put standard ANSI color codes in environment for easy use
reset_color="$(echo -n '\e[0m')"
bold_color="$(echo -n '\e[1m')"
# Foreground
fg_grey="$(echo -n '\e[30m')"
fg_red="$(echo -n '\e[31m')"
fg_green="$(echo -n '\e[32m')"
fg_yellow="$(echo -n '\e[33m')"
fg_blue="$(echo -n '\e[34m')"
fg_magenta="$(echo -n '\e[35m')"
fg_cyan="$(echo -n '\e[36m')"
fg_white="$(echo -n '\e[37m')"
fg_no_bold_grey="$(echo -n '\e[0;30m')"
fg_no_bold_red="$(echo -n '\e[0;31m')"
fg_no_bold_green="$(echo -n '\e[0;32m')"
fg_no_bold_yellow="$(echo -n '\e[0;33m')"
fg_no_bold_blue="$(echo -n '\e[0;34m')"
fg_no_bold_magenta="$(echo -n '\e[0;35m')"
fg_no_bold_cyan="$(echo -n '\e[0;36m')"
fg_no_bold_white="$(echo -n '\e[0;37m')"
fg_bold_grey="$(echo -n '\e[1;30m')"
fg_bold_red="$(echo -n '\e[1;31m')"
fg_bold_green="$(echo -n '\e[1;32m')"
fg_bold_yellow="$(echo -n '\e[1;33m')"
fg_bold_blue="$(echo -n '\e[1;34m')"
fg_bold_magenta="$(echo -n '\e[1;35m')"
fg_bold_cyan="$(echo -n '\e[1;36m')"
fg_bold_white="$(echo -n '\e[1;37m')"
# Background
bg_grey="$(echo -n '\e[40m')"
bg_red="$(echo -n '\e[41m')"
bg_green="$(echo -n '\e[42m')"
bg_yellow="$(echo -n '\e[43m')"
bg_blue="$(echo -n '\e[44m')"
bg_magenta="$(echo -n '\e[45m')"
bg_cyan="$(echo -n '\e[46m')"
bg_white="$(echo -n '\e[47m')"
bg_no_bold_grey="$(echo -n '\e[0;40m')"
bg_no_bold_red="$(echo -n '\e[0;41m')"
bg_no_bold_green="$(echo -n '\e[0;42m')"
bg_no_bold_yellow="$(echo -n '\e[0;43m')"
bg_no_bold_blue="$(echo -n '\e[0;44m')"
bg_no_bold_magenta="$(echo -n '\e[0;45m')"
bg_no_bold_cyan="$(echo -n '\e[0;46m')"
bg_no_bold_white="$(echo -n '\e[0;47m')"
bg_bold_grey="$(echo -n '\e[1;40m')"
bg_bold_red="$(echo -n '\e[1;41m')"
bg_bold_green="$(echo -n '\e[1;42m')"
bg_bold_yellow="$(echo -n '\e[1;43m')"
bg_bold_blue="$(echo -n '\e[1;44m')"
bg_bold_magenta="$(echo -n '\e[1;45m')"
bg_bold_cyan="$(echo -n '\e[1;46m')"
bg_bold_white="$(echo -n '\e[1;47m')"
# Stop these screwing the environment listing up
bg_zzzz=$reset_color
fg_zzzz=$reset_color
bold_zzzz=$reset_color

View File

@ -0,0 +1,33 @@
# adam1 prompt theme
prompt_adam1_setup () {
base_prompt="%{$bg_no_bold_blue%}%n@%m%{$reset_color%} "
post_prompt="%{$reset_color%}"
base_prompt_no_color=$(echo "$base_prompt" | perl -pe "s/%{.*?%}//g")
post_prompt_no_color=$(echo "$post_prompt" | perl -pe "s/%{.*?%}//g")
precmd () { prompt_adam1_precmd }
preexec () { }
}
prompt_adam1_precmd () {
setopt noxtrace localoptions
local base_prompt_expanded_no_color base_prompt_etc
local prompt_length space_left
base_prompt_expanded_no_color=$(print -P "$base_prompt_no_color")
base_prompt_etc=$(print -P "$base_prompt%(4~|...|)%3~")
prompt_length=${#base_prompt_etc}
if [[ $prompt_length -lt 40 ]]; then
path_prompt="%{$fg_bold_cyan%}%(4~|...|)%3~%{$fg_bold_white%}"
else
space_left=$(( $COLUMNS - $#base_prompt_expanded_no_color - 2 ))
path_prompt="%{$fg_bold_green%}%${space_left}<...<%~$prompt_newline%{$fg_bold_white%}"
fi
PS1="$base_prompt$path_prompt %# $post_prompt"
PS2="$base_prompt$path_prompt %_> $post_prompt"
PS3="$base_prompt$path_prompt ?# $post_prompt"
}
prompt_adam1_setup "$@"

View File

@ -0,0 +1,116 @@
# adam2 prompt theme
prompt_adam2_help () {
cat <<'EOF'
This prompt is color-theme-able. You can invoke it thus:
prompt adam2 [ simple ] <color1> <color2> <color3>
where the colors are for the hyphens, current directory, and user@host
bits respectively.
And you probably thought adam1 was overkill. If you've ever seen a
more complex prompt in your whole life, please e-mail it to me at
<adam@spiers.net>; I'd love to know that I'm not the saddest person
on the planet.
EOF
}
prompt_adam2_setup () {
# Some can't be local
local prompt_gfx_tlc prompt_gfx_mlc prompt_gfx_blc prompt_gfx_bbox
if [[ $1 == 'plain' ]]; then
shift
prompt_gfx_tlc='.'
prompt_gfx_mlc='|'
prompt_gfx_blc='\`'
prompt_gfx_hyphen='-'
else
prompt_gfx_tlc=$(echo "\xda")
prompt_gfx_mlc=$(echo "\xc3")
prompt_gfx_blc=$(echo "\xc0")
prompt_gfx_hyphen=$(echo "\xc4")
fi
# Colour scheme
prompt_scheme_color1=${1:-'cyan'} # hyphens
prompt_scheme_color2=${2:-'green'} # current directory
prompt_scheme_color3=${3:-'cyan'} # user@host
local num
for num in 1 2 3; do
# Grok this!
eval "prompt_color$num="'${(P)$(echo "fg_no_bold_$prompt_scheme_color'"$num\")}"
eval "prompt_bold_color$num="'${(P)$(echo "fg_bold_$prompt_scheme_color'"$num\")}"
done
prompt_gfx_tbox=$(echo "%{$prompt_bold_color1%}${prompt_gfx_tlc}%{$prompt_color1%}${prompt_gfx_hyphen}")
prompt_gfx_bbox=$(echo "%{$prompt_bold_color1%}${prompt_gfx_blc}${prompt_gfx_hyphen}%{$prompt_color1%}")
# This is a cute hack. Well I like it, anyway.
prompt_gfx_bbox_to_mbox=$(echo "%{\e[A\r$prompt_bold_color1${prompt_gfx_mlc}$prompt_color1${prompt_gfx_hyphen}\e[B%}")
prompt_l_paren=$(echo "%{$fg_bold_grey%}(")
prompt_r_paren=$(echo "%{$fg_bold_grey%})")
prompt_l_bracket=$(echo "%{$fg_bold_grey%}[")
prompt_r_bracket=$(echo "%{$fg_bold_grey%}]")
prompt_machine=$(echo "%{$prompt_color3%}%n%{$prompt_bold_color3%}@%{$prompt_color3%}%m")
prompt_padding_text=`perl -e "print qq{${prompt_gfx_hyphen}} x 200"`
prompt_line_1a="$prompt_gfx_tbox$prompt_l_paren%{$prompt_bold_color2%}%~$prompt_r_paren%{$prompt_color1%}"
prompt_line_1a_no_color=$(echo "$prompt_line_1a" | perl -pe "s/%{.*?%}//g")
prompt_line_1b=$(echo "$prompt_l_paren$prompt_machine$prompt_r_paren%{$prompt_color1%}${prompt_gfx_hyphen}")
prompt_line_1b_no_color=$(echo "$prompt_line_1b" | perl -pe "s/%{.*?%}//g")
prompt_line_2="$prompt_gfx_bbox${prompt_gfx_hyphen}%{$fg_bold_white%}"
prompt_char="%(!.#.>)"
precmd () { prompt_adam2_precmd }
preexec () { prompt_adam2_preexec }
}
prompt_adam2_precmd () {
setopt noxtrace localoptions
local prompt_line_1a_no_color_expanded prompt_line_2a_no_color_expanded
local prompt_padding_size prompt_padding prompt_line_1 pre_prompt
local prompt_pwd_size
prompt_line_1a_no_color_expanded=$(print -P "$prompt_line_1a_no_color")
prompt_line_1b_no_color_expanded=$(print -P "$prompt_line_1b_no_color")
prompt_padding_size=$(( $COLUMNS
- $#prompt_line_1a_no_color_expanded
- $#prompt_line_1b_no_color_expanded ))
if [[ $prompt_padding_size -ge 0 ]]; then
prompt_padding=$(printf "%$prompt_padding_size.${prompt_padding_size}s" "$prompt_padding_text")
prompt_line_1="$prompt_line_1a$prompt_padding$prompt_line_1b"
else
prompt_padding_size=$(( $COLUMNS
- $#prompt_line_1a_no_color_expanded ))
if [[ $prompt_padding_size -ge 0 ]]; then
prompt_padding=$(printf "%$prompt_padding_size.${prompt_padding_size}s" "$prompt_padding_text")
prompt_line_1="$prompt_line_1a$prompt_padding"
else
prompt_pwd_size=$(( $COLUMNS - 5 ))
prompt_line_1="$prompt_gfx_tbox$prompt_l_paren%{$prompt_bold_color2%}%$prompt_pwd_size<...<%~%<<$prompt_r_paren%{$prompt_color1$prompt_gfx_hyphen%}"
fi
fi
pre_prompt="$prompt_line_1$prompt_newline$prompt_line_2"
PS1="$pre_prompt%{$fg_bold_white%}$prompt_char "
PS2="$prompt_line_2%{$prompt_gfx_bbox_to_mbox$fg_bold_white%}%_> "
PS3="$prompt_line_2%{$prompt_gfx_bbox_to_mbox$fg_bold_white%}?# "
}
prompt_adam2_preexec () {
print -n "$fg_no_bold_white"
}
prompt_adam2_setup "$@"

View File

@ -0,0 +1,23 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Blue
# Created by BadlandZ in v.0.4b
# Adapted by jf
# Changed By Spidey 08/06 Adding Ending brackets %}
#
prompt_blue_setup () {
PS1="%{$fg_blue$bg_blue$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_blue$bold_color%}%n@%m%{$reset_color%}\
%{$fg_blue$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} \
%D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg_blue$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_blue$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_blue_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 260 261 262 333 333 262 261 260 333 262 261 260 260 261 262 333 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by James Manning <jmm@raleigh.ibm.com>
# Changed by Spidey 08/06
prompt_combo_setup () {
PS1="%{$bold_color$fg_blue$bold_color%}$char_333$char_262$char_261$char_260%{$bold_color$fg_white$bg_blue%}%n@%m%{$reset_color$fg_blue$bg_grey%}$char_260$char_261$char_262$char_333%{$reset_color$fg_blue$bg_grey%}$char_333$char_262$char_261$char_260%{$bold_color$fg_white$bg_grey%} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%{$bold_color$fg_yellow$bg_grey%}$PWD>%{$reset_color%} "
PS2="%{$bold_color$fg_blue$bold_color%}$char_333$char_262$char_261$char_260%{$reset_color$fg_blue$bg_grey%}$char_260$char_261$char_262$char_333%{$reset_color$fg_blue$bg_grey%}$char_333$char_262$char_261$char_260%{$bold_color$bold_color$fg_blue%}>%{$reset_color%} "
precmd () { }
preexec () { }
}
prompt_combo_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by Jim Foltz <aa204@acorn.net>
# Changed by Spidey 08/06
prompt_cyan_setup () {
PS1="%{$fg_cyan$bg_cyan$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_cyan$bold_color%}%n@%m%{$reset_color$fg_cyan$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg_cyan$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_cyan$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_cyan_setup "$@"

View File

@ -0,0 +1,17 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
# Created by icetrey <trey@imagin.net>
# Added by Spidey 08/06
prompt_elite2_setup () {
local GRAD1=`tty|cut -d/ -f3`
local COLOR1="%{$reset_color$fg_cyan%}"
local COLOR2="%{$bold_color$fg_cyan%}"
local COLOR3="%{$bold_color$fg_grey%}"
local COLOR4="%{$reset_color%}"
PS1="$COLOR3<52>Ś$COLOR1<52>g$COLOR2($COLOR1%n$COLOR3@$COLOR1%m$COLOR2)$COLOR1<52>g$COLOR2($COLOR1%!$COLOR3/$COLOR1$GRAD1$COLOR2)$COLOR1<52>g$COLOR2($COLOR1%D{%I:%M%P}$COLOR3:$COLOR1%D{%m/%d/%y}$COLOR2)$COLOR1<52>g$COLOR3-$COLOR4$prompt_newline$COLOR3<52>^$COLOR1<52>g$COLOR2($COLOR1%#$COLOR3:$COLOR1%~$COLOR2)$COLOR1<52>g$COLOR3-$COLOR4 "
PS2="$COLOR2<52>g$COLOR1<52>g$COLOR3-$COLOR4 "
precmd () { }
preexec () { }
}
prompt_elite2_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 332 304 304 371 371 371 372 300 304 304 371 372; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by KrON from windowmaker on IRC
# Changed by Spidey 08/06
prompt_elite_setup () {
PS1="%{$fg_red%}$char_332$char_304%{$fg_blue%}(%{$fg_red%}%n%{$fg_blue%}@%{$fg_red%}%m%{$fg_blue%})%{$fg_red%}-%{$fg_blue%}(%{$fg_red%}%D{%I:%M%P}%{$fg_blue%}-:-%{$fg_red%}%D{%m}%{$fg_blue$fg_red%}/%D{%d}%{$fg_blue%})%{$fg_red%}$char_304-%{$fg_blue]%}$char_371%{$fg_red%}-$char_371$char_371%{$fg_blue%}$char_372$prompt_newline%{$fg_red%}$char_300$char_304%{$fg_blue%}(%{$fg_red%}%1~%{$fg_blue%})%{$fg_red%}$char_304$char_371%{$fg_blue%}$char_372%{$reset_color%}"
PS2="> "
precmd () { }
preexec () { }
}
prompt_elite_setup "$@"

View File

@ -0,0 +1,28 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 260 261 262 333; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Inspired by Raster (Carsten Haitzler of Red Hat Advanced Development Labs)
# Created by BadlandZ
# Changed by Spidey 08/06
prompt_fire_setup () {
local GRAD1='%{$char_333$char_262$char_261$char_260%}'
local GRAD2='%{$char_260$char_261$char_262$char_333%}'
local COLOR1='%{$bold_color$fg_yellow$bg_yellow%}'
local COLOR2='%{$bold_color$fg_white$bg_yellow%}'
local COLOR3='%{$reset_color$fg_red$bg_yellow%}'
local COLOR4='%{$reset_color$fg_red$bg_grey%}'
local COLOR5='%{$bold_color$fg_yellow$bg_grey%}'
local COLOR6='%{$bold_color$fg_white$bg_grey%}'
local GRAD0='%{$reset_color%}'
PS1=$COLOR1$GRAD1$COLOR2'%n@%m'$COLOR3$GRAD2$COLOR4$GRAD1$COLOR6' %D{%a %b %d} %D{%I:%M:%S%P} '$NONE'$prompt_newline'$COLOR5'%~/'$GRAD0' '
PS2=$COLOR1$GRAD1$COLOR3$GRAD2$COLOR4$GRAD1$COLOR5'>'$GRAD0' '
precmd () { }
preexec () { }
}
prompt_fire_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by Jim Foltz <aa204@acorn.net>
# Changed by Spidey 08/06
prompt_green_setup () {
PS1="%{$fg_green$bg_green$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_green$bold_color%}%n@%m%{$reset_color$fg_green$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg_green$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_green$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_green_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by Jim Foltz <aa204@acorn.net>
# Changed by Spidey 08/06
prompt_magenta_setup () {
PS1="%{$fg_magenta$bg_magenta$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_magenta$bold_color%}%n@%m%{$reset_color$fg_magenta$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg_magenta$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_magenta$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_magenta_setup "$@"

View File

@ -0,0 +1,11 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
# Very simple prompt
prompt_off_setup () {
PS1="%# "
PS2="> "
precmd () { }
preexec () { }
}
prompt_off_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by Jim Foltz <aa204@acorn.net>
# Changed by Spidey 08/06
prompt_red_setup () {
PS1="%{$fg_red$bg_red$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_red$bold_color%}%n@%m%{$reset_color$fg_red$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%{$fg_red$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_red$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_red_setup "$@"

View File

@ -0,0 +1,13 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
# Red Hat Default Prompt
# Styled like the default prompt in Red Hat 5.1
#
prompt_redhat_setup () {
PS1="[%n@%m %1~]\\$ "
PS2="> "
precmd () { }
preexec () { }
}
prompt_redhat_setup "$@"

View File

@ -0,0 +1,13 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
# SuSE Default Prompt
# Styled like the default prompt in SuSE 5.2
#
prompt_suse_setup () {
PS1="%n@%m:%~/ > "
PS2="> "
precmd () { }
preexec () { }
}
prompt_suse_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by Jim Foltz <aa204@acorn.net>
# Changed by Spidey 08/06
prompt_white_setup () {
PS1="%{$fg_white$bg_white$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_white$bold_color%}%n@%m%{$reset_color$fg_white$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg_white$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_white$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_white_setup "$@"

View File

@ -0,0 +1,18 @@
# Converted to zsh prompt theme by bash2zshprompt, written by <adam@spiers.net>
for code in 333 262 261 260 333 262 261 260 333 262 261 260; do
local varname=char_$code
: ${(P)varname=$(echo -n "\\0$code")}
done
# Created by Jim Foltz <aa204@acorn.net>
# Changed by Spidey 08/06
prompt_yellow_setup () {
PS1="%{$fg_yellow$bg_yellow$bold_color%}$char_333$char_262$char_261$char_260%{$fg_white$bg_yellow$bold_color%}%n@%m%{$reset_color$fg_yellow$bg_grey%}$char_333$char_262$char_261$char_260%{$fg_white$bg_grey$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%{$fg_yellow$bg_grey$bold_color%}%~/%{$reset_color%} "
PS2="%{$fg_yellow$bg_grey%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
precmd () { }
preexec () { }
}
prompt_yellow_setup "$@"

View File

@ -0,0 +1,107 @@
# zsh prompt themes extension
#
# Load with `autoload -U promptinit; promptinit'.
prompt_themes=()
typeset -gU prompt_themes
typeset -g prompt_theme
promptinit () {
emulate -L zsh
local ppath='' name
# Autoload all prompt_*_setup functions in fpath
for theme in $fpath/prompt_*_setup(N); do
if [[ $theme == */prompt_(#b)(*)_setup ]]; then
name="$match[1]"
if [[ -r "$theme" ]]; then
prompt_themes=($name $prompt_themes)
autoload -U prompt_${name}_setup
else
print "Couldn't find theme $theme"
fi
else
print "eh?"
fi
done
# Color definitions come in handy
autoload -U colors
colors
# Variables common to all prompt styles
prompt_newline=$(echo -ne "\n%{\r%}")
}
prompt () {
local opt preview theme usage old_theme
usage='Usage: prompt <options>
Options:
-l List currently available prompt themes
-p [<themes>] Preview given themes (defaults to all)
-h [<theme>] Display help (for given theme)
-s <theme> Set and save theme
<theme> Switch to new theme immediately (changes not saved)'
getopts "hlps" opt
case "$opt" in
h) if [[ -n "$2" && -n $prompt_themes[(r)$2] ]]; then
if functions prompt_$2_help >/dev/null; then
print "Help for $2 theme:\n"
prompt_$2_help
else
print "No help available for $2 theme"
fi
else
print "$usage"
fi
;;
l) print Currently available prompt themes:
print $prompt_themes
return
;;
p) if (( ! $+prompt_theme )); then
print "Cannot preview; current prompt is non-themeable and would"
print "be destroyed."
return
fi
preview=( $prompt_themes )
[[ -n "$2" && -n $prompt_themes[(r)$2] ]] && preview=( $*[2,-1] )
for theme in $preview; do
[[ $theme == $prompt_theme[1] ]] && continue
print "\nTheme: $theme"
prompt_${theme}_setup
precmd
print -n -P "${PS1}"
preexec
print "command arg1 arg2 ... argn"
done
print
prompt_${prompt_theme}_setup
;;
s) print "Set and save not yet implemented. Please ensure your ~/.zshrc"
print "contains something similar to the following:\n"
print " autoload -U promptinit"
print " promptinit"
print " prompt $*[2,-1]"
;;
*) if [[ -z "$1" || -z $prompt_themes[(r)$1] ]]; then
print "$usage"
return
fi
prompt_$1_setup "$*[2,-1]"
prompt_theme=( $* )
# Avoid screwing up the environment listing
PSZZZZ=$reset_color
RPSZZZZ=$reset_color
PROMPTZZZZ=$reset_color
RPROMPTZZZZ=$reset_color
promptzzzz=$reset_color
;;
esac
}
promptinit "$@"

100
Misc/bash2zshprompt Normal file
View File

@ -0,0 +1,100 @@
#!/usr/bin/perl -w
#
# exceedingly ugly hack to convert bashprompt themes to zshprompt themes
# (bashprompt is at http://bash.current.nu/)
#
# Adam Spiers <adam@spiers.net>
use strict;
my @colours = qw/grey red green yellow blue magenta cyan white/;
my @codes = ();
my %bold;
my $out = '';
print "# Converted to zsh prompt theme by bash2zshprompt, written by <adam\@spiers.net>\n";
my $seen_fn = 0;
my $seen_fn_end = 0;
while (<>) {
# Ugh
if (! $seen_fn) {
s/^\s*function (\w+) {\s*$/prompt_$1_setup () {\n/ and $seen_fn = $1;
}
# UGH
elsif (! $seen_fn_end && $seen_fn) {
s/^\s*/ /;
s/^\s*}\s*$/\n precmd () { }\n preexec () { }\n}\n/ and $seen_fn_end++;
}
s/\\\[/%{/g;
s/\\\]/%}/g;
s/\\033/\\e/g;
s/\\e\[([0-9;]+)m/split_codes($1)/eg;
s/\\e\[((\d?)(\d))m/color()/eg;
s/(?<!\\)\\u/%n/g;
s/(?<!\\)\\h/%m/g;
s/(?<!\\)\\t/%t/g;
s/(?<!\\)\\d/%D{%a %b %d}/g;
s/(?<!\\)\\?\$\(date\s+\+([^)]+)\)/%D{$1}/g;
s/(?<!\\)\\!/%!/g;
s/(?<!\\)\\#/%!/g; # hmmm
s/(?<!\\)\\n/\$prompt_newline/g;
s/(?<!\\)\\s/\$SHELL/g;
s/(?<!\\)\\w/%~/g;
s/(?<!\\)\\W/%1~/g;
s/(?<!\\)\\\$(?!\()/%\#/g;
s/(?<!\\)\\0?(\d{3})/push @codes, $1; "\$char_$1"/eg;
s/%}%{//g;
$out .= $_;
}
# Must be a better way of doing this
print <<EOF if @codes;
for code in @codes; do
local varname=char_\$code
: \${(P)varname=\$(echo -n "\\\\0\$code")}
done
EOF
print $out;
print qq!\nprompt_${seen_fn}_setup "\$@"\n! if $seen_fn;
exit 0;
sub color {
my @p = ($1, $2, $3);
my $fgbg = (($p[1] eq '3') ? 'fg' :
($p[1] eq '4') ? 'bg' :
'???');
$bold{$fgbg} ||= '';
if ($p[0] =~ /^0?0$/) {
$bold{$fgbg} = '';
return '$reset_color';
}
if ($p[0] =~ /^0?1$/) {
$bold{$fgbg} = 'bold_';
return '$bold_color';
}
return '$' .
"${fgbg}_$bold{$fgbg}" .
$colours[$p[2]];
}
sub split_codes {
join '', (map { "\\e\[${_}m" } (split m!;!, $_[0]));
}