Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: prompt fun



Here's a more light-hearted addition, which I've finally got round to
turning into a releasable form -- themeable prompts.  Those of
you with any taste will probably wince at this point, but it would
really be nice to see zsh getting the kind of mainstream attention it
deserves, and the sad fact is that most command-line hackers in the
newer generation of the culture appreciate a fancy prompt more than an
amazing completion system (only because they've never experienced the
latter, though).  Besides, bash has bashprompt, and I don't like bash
having anything zsh doesn't ...

This patch adds:

Functions/Prompts/promptinit
  -- in a direct parallel with compinit, sets up the prompt themes system

Completion/User/_prompt
  -- completion for `prompt', the command which controls the system

Functions/Misc/colors
  -- a bunch of ANSI colou?rs

Misc/bash2zshprompt
  -- an evil, ugly hack for converting bashprompt themes to the system
     (don't look at this for too long :-)

Functions/Prompts/prompt_*_setup
  -- a whole load of themes, some very simple, some excessively fancy
     (all autoloaded, of course).  Some aren't 8-bit clean; let me
     know if this is a problem.

To play with the system:

  autoload -U promptinit
  promptinit
  prompt -h

`prompt -p' gives a preview of all the themes, which is quite cute.

Suggestions on how to improve the mess with $(echo <ANSI codes>)
welcome, as are comments on how many of the themes belong in the
distribution, or any other comments for that matter.

Index: Completion/User/_prompt
===================================================================
RCS file: _prompt
diff -N _prompt
--- /dev/null	Tue May  5 21:32:27 1998
+++ _prompt	Mon Oct  4 18:04:35 1999
@@ -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):*:"
Index: Functions/Misc/colors
===================================================================
RCS file: colors
diff -N colors
--- /dev/null	Tue May  5 21:32:27 1998
+++ colors	Mon Oct  4 18:41:11 1999
@@ -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
Index: Functions/Prompts/prompt_adam1_setup
===================================================================
RCS file: prompt_adam1_setup
diff -N prompt_adam1_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_adam1_setup	Mon Oct  4 18:11:15 1999
@@ -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 "$@"
Index: Functions/Prompts/prompt_adam2_setup
===================================================================
RCS file: prompt_adam2_setup
diff -N prompt_adam2_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_adam2_setup	Mon Oct  4 18:49:05 1999
@@ -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@xxxxxxxxxx>; 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 "$@"
Index: Functions/Prompts/prompt_blue_setup
===================================================================
RCS file: prompt_blue_setup
diff -N prompt_blue_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_blue_setup	Mon Oct  4 17:42:42 1999
@@ -0,0 +1,23 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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 "$@"
Index: Functions/Prompts/prompt_combo_setup
===================================================================
RCS file: prompt_combo_setup
diff -N prompt_combo_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_combo_setup	Mon Oct  4 17:42:42 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_cyan_setup
===================================================================
RCS file: prompt_cyan_setup
diff -N prompt_cyan_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_cyan_setup	Mon Oct  4 17:42:42 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_elite2_setup
===================================================================
RCS file: prompt_elite2_setup
diff -N prompt_elite2_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_elite2_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,17 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+# Created by icetrey <trey@xxxxxxxxxx>
+# 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Ú$COLOR1Ä$COLOR2($COLOR1%n$COLOR3@$COLOR1%m$COLOR2)$COLOR1Ä$COLOR2($COLOR1%!$COLOR3/$COLOR1$GRAD1$COLOR2)$COLOR1Ä$COLOR2($COLOR1%D{%I:%M%P}$COLOR3:$COLOR1%D{%m/%d/%y}$COLOR2)$COLOR1Ä$COLOR3-$COLOR4$prompt_newline$COLOR3À$COLOR1Ä$COLOR2($COLOR1%#$COLOR3:$COLOR1%~$COLOR2)$COLOR1Ä$COLOR3-$COLOR4 " 
+  PS2="$COLOR2Ä$COLOR1Ä$COLOR3-$COLOR4 "
+
+  precmd () { }
+  preexec () { }
+}
+
+prompt_elite2_setup "$@"
Index: Functions/Prompts/prompt_elite_setup
===================================================================
RCS file: prompt_elite_setup
diff -N prompt_elite_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_elite_setup	Mon Oct  4 17:49:04 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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 "$@"
Index: Functions/Prompts/prompt_fire_setup
===================================================================
RCS file: prompt_fire_setup
diff -N prompt_fire_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_fire_setup	Mon Oct  4 17:53:08 1999
@@ -0,0 +1,28 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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 "$@"
Index: Functions/Prompts/prompt_green_setup
===================================================================
RCS file: prompt_green_setup
diff -N prompt_green_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_green_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_magenta_setup
===================================================================
RCS file: prompt_magenta_setup
diff -N prompt_magenta_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_magenta_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_off_setup
===================================================================
RCS file: prompt_off_setup
diff -N prompt_off_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_off_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,11 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+# Very simple prompt
+prompt_off_setup () {
+  PS1="%# "
+  PS2="> "
+
+  precmd () { }
+  preexec () { }
+}
+
+prompt_off_setup "$@"
Index: Functions/Prompts/prompt_red_setup
===================================================================
RCS file: prompt_red_setup
diff -N prompt_red_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_red_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_redhat_setup
===================================================================
RCS file: prompt_redhat_setup
diff -N prompt_redhat_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_redhat_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,13 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_suse_setup
===================================================================
RCS file: prompt_suse_setup
diff -N prompt_suse_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_suse_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,13 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+# SuSE Default Prompt
+# Styled like the default prompt in SuSE 5.2
+#
+prompt_suse_setup () {
+  PS1="%n@%m:%~/ > "
+  PS2="> "
+
+  precmd () { }
+  preexec () { }
+}
+
+prompt_suse_setup "$@"
Index: Functions/Prompts/prompt_white_setup
===================================================================
RCS file: prompt_white_setup
diff -N prompt_white_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_white_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/prompt_yellow_setup
===================================================================
RCS file: prompt_yellow_setup
diff -N prompt_yellow_setup
--- /dev/null	Tue May  5 21:32:27 1998
+++ prompt_yellow_setup	Mon Oct  4 17:42:43 1999
@@ -0,0 +1,18 @@
+# Converted to zsh prompt theme by bash2zshprompt, written by <adam@xxxxxxxxxx>
+
+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@xxxxxxxxx>
+# 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 "$@"
Index: Functions/Prompts/promptinit
===================================================================
RCS file: promptinit
diff -N promptinit
--- /dev/null	Tue May  5 21:32:27 1998
+++ promptinit	Mon Oct  4 18:46:50 1999
@@ -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 "$@"
+
Index: Misc/bash2zshprompt
===================================================================
RCS file: bash2zshprompt
diff -N bash2zshprompt
--- /dev/null	Tue May  5 21:32:27 1998
+++ bash2zshprompt	Mon Oct  4 17:35:14 1999
@@ -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@xxxxxxxxxx>
+
+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]));
+}



Messages sorted by: Reverse Date, Date, Thread, Author