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

Re: Eterm and prompt themes



On Thu, 14 Jun 2007 11:06:19 -0400
jadamson@xxxxxxxxxxxx (Joel J. Adamson) wrote:
> I like using Eterm and I also like using prompt themes.  I recently
> noticed that the "fade," "fire," and "elite" prompt themes only
> display correctly in Konsole with Central European (ibm852) encoding
> set from the "Settings" menu.  The only one that looks worth using is
> "adam2."  Pretty cool but I like to change things up every now and
> then.

I just looked and the current code is a bit of a hack even by zsh
standards.  I've made the code work with UTF-8 (I simply ran iconv by hand
to work out the appropriate characters).  This requires your locale to be
set properly, but that's the right way to do it anyway.

In theory we could be more inventive with run-time iconv.  It's unlikely to
work with a randomly chosen 8-bit character set since they focus on useful
characters rather than eye candy, so I'm not that bothered.

I haven't tackled adam1 since although it mentioned funny fonts I
couldn't see any use of them.

Index: Functions/Prompts/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/.distfiles,v
retrieving revision 1.4
diff -u -r1.4 .distfiles
--- Functions/Prompts/.distfiles	7 Feb 2002 07:35:15 -0000	1.4
+++ Functions/Prompts/.distfiles	14 Jun 2007 15:46:23 -0000
@@ -6,4 +6,5 @@
 prompt_bigfade_setup  prompt_off_setup      promptinit
 prompt_elite2_setup   prompt_oliver_setup   prompt_clint_setup
 prompt_walters_setup
+prompt_special_chars
 '
Index: Functions/Prompts/prompt_adam2_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_adam2_setup,v
retrieving revision 1.4
diff -u -r1.4 prompt_adam2_setup
--- Functions/Prompts/prompt_adam2_setup	19 Aug 2003 21:59:00 -0000	1.4
+++ Functions/Prompts/prompt_adam2_setup	14 Jun 2007 15:46:24 -0000
@@ -10,8 +10,8 @@
 and user input bits respectively.  The default colors are cyan, green,
 cyan, and white.  This theme works best with a dark background.
 
-If you have the `nexus' or `vga' console fonts or similar, you
-can specify the `8bit' option to use 8-bit replacements for the
+If you have either UTF-8 or the `nexus' or `vga' console fonts or similar,
+you can specify the `8bit' option to use 8-bit replacements for the
 7-bit characters.
 
 And you probably thought adam1 was overkill ...
@@ -24,10 +24,17 @@
 
   if [[ $1 == '8bit' ]]; then
     shift
-    prompt_gfx_tlc=$'\xda'
-    prompt_gfx_mlc=$'\xc3'
-    prompt_gfx_blc=$'\xc0'
-    prompt_gfx_hyphen=$'\xc4'
+    if [[ ${LC_ALL:-${LC_CTYPE:-$LANG}} = *UTF-8* ]]; then
+      prompt_gfx_tlc=$'\xe2\x94\x8c'
+      prompt_gfx_mlc=$'\xe2\x94\x9c'
+      prompt_gfx_blc=$'\xe2\x94\x94'
+      prompt_gfx_hyphen=$'\xe2\x94\x80'
+    else
+      prompt_gfx_tlc=$'\xda'
+      prompt_gfx_mlc=$'\xc3'
+      prompt_gfx_blc=$'\xc0'
+      prompt_gfx_hyphen=$'\xc4'
+    fi
   else
     prompt_gfx_tlc='.'
     prompt_gfx_mlc='|'
Index: Functions/Prompts/prompt_bigfade_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_bigfade_setup,v
retrieving revision 1.2
diff -u -r1.2 prompt_bigfade_setup
--- Functions/Prompts/prompt_bigfade_setup	10 May 2005 04:39:02 -0000	1.2
+++ Functions/Prompts/prompt_bigfade_setup	14 Jun 2007 15:46:24 -0000
@@ -14,8 +14,10 @@
 colors are blue, white, white, and yellow.  This theme works best with
 a dark background.
 
-Recommended fonts for this theme: nexus or vga or similar.  If you
-don't have any of these, the 8-bit characters will probably look stupid.
+
+Recommended fonts for this theme: either UTF-8, or nexus or vga or similar.
+If you don't have any of these, the 8-bit characters will probably look
+stupid.
 EOH
 }
 
@@ -25,9 +27,9 @@
   local date=${3:-'white'}
   local cwd=${4:-'yellow'}
 
-  for code in 333 262 261 260; do
-    local char_$code=$(echo -n "\\0$code")
-  done
+  local char_333 char_262 char_261 char_260
+  autoload -U prompt_special_chars
+  prompt_special_chars
 
   PS1="%{$bold_color$fg[$fadebar]$bold_color%}$char_333$char_262$char_261$char_260%{$bold_color$fg[$userhost]$bg[$fadebar]%}%n@%m%{$reset_color$fg[$fadebar]$bg[grey]%}$char_260$char_261$char_262$char_333%{$reset_color$fg[$fadebar]$bg[grey]%}$char_333$char_262$char_261$char_260%{$bold_color$fg[$date]$bg[grey]%} %D{%a %b %d} %D{%I:%M:%S%P}$prompt_newline%{$bold_color$fg[$cwd]$bg[grey]%}$PWD>%{$reset_color%} "
   PS2="%{$bold_color$fg[$fadebar]$bold_color%}$char_333$char_262$char_261$char_260%{$reset_color$fg[$fadebar]$bg[grey]%}$char_260$char_261$char_262$char_333%{$reset_color$fg[$fadebar]$bg[grey]%}$char_333$char_262$char_261$char_260%{$bold_color$bold_color$fg[$fadebar]%}>%{$reset_color%} "
Index: Functions/Prompts/prompt_elite2_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_elite2_setup,v
retrieving revision 1.3
diff -u -r1.3 prompt_elite2_setup
--- Functions/Prompts/prompt_elite2_setup	10 May 2005 04:39:02 -0000	1.3
+++ Functions/Prompts/prompt_elite2_setup	14 Jun 2007 15:46:24 -0000
@@ -11,8 +11,9 @@
 The default colors are both cyan.  This theme works best with a dark
 background.
 
-Recommended fonts for this theme: nexus or vga or similar.  If you
-don't have any of these, the 8-bit characters will probably look stupid.
+Recommended fonts for this theme: either UTF-8, or nexus or vga or similar.
+If you don't have any of these, the 8-bit characters will probably look
+stupid.
 EOH
 }
 
@@ -20,9 +21,9 @@
   local text_col=${1:-'cyan'}
   local parens_col=${2:-$text_col}
 
-  for code in 332 304 300; do
-    local char_$code=$(echo -n "\\0$code")
-  done
+  local char_333 char_262 char_261 char_260
+  autoload -U prompt_special_chars
+  prompt_special_chars
 
   local text="%{$fg_no_bold[$text_col]%}"
   local parens="%{$fg_bold[$parens_col]%}"
Index: Functions/Prompts/prompt_elite_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_elite_setup,v
retrieving revision 1.2
diff -u -r1.2 prompt_elite_setup
--- Functions/Prompts/prompt_elite_setup	10 May 2005 04:39:02 -0000	1.2
+++ Functions/Prompts/prompt_elite_setup	14 Jun 2007 15:46:24 -0000
@@ -11,8 +11,9 @@
 The default colors are red and blue respectively.  This theme is
 intended for use with a black background.
 
-Recommended fonts for this theme: nexus or vga or similar.  If you
-don't have any of these, the 8-bit characters will probably look stupid.
+Recommended fonts for this theme: either UTF-8, or nexus or vga or similar.
+If you don't have any of these, the 8-bit characters will probably look
+stupid.
 EOH
 }
 
@@ -20,9 +21,9 @@
   local text=${1:-'red'}
   local punctuation=${2:-'blue'}
 
-  for code in 332 304 371 372 300; do
-    local char_$code=$(echo -n "\\0$code")
-  done
+  local char_333 char_262 char_261 char_260
+  autoload -U prompt_special_chars
+  prompt_special_chars
 
   PS1="%{$fg[$text]%}$char_332$char_304%{$fg[$punctuation]%}(%{$fg[$text]%}%n%{$fg[$punctuation]%}@%{$fg[$text]%}%m%{$fg[$punctuation]%})%{$fg[$text]%}-%{$fg[$punctuation]%}(%{$fg[$text]%}%D{%I:%M%P}%{$fg[$punctuation]%}-:-%{$fg[$text]%}%D{%m}%{$fg[$punctuation]$fg[$text]%}/%D{%d}%{$fg[$punctuation]%})%{$fg[$text]%}$char_304-%{$fg[$punctuation]]%}$char_371%{$fg[$text]%}-$char_371$char_371%{$fg[$punctuation]%}$char_372$prompt_newline%{$fg[$text]%}$char_300$char_304%{$fg[$punctuation]%}(%{$fg[$text]%}%1~%{$fg[$punctuation]%})%{$fg[$text]%}$char_304$char_371%{$fg[$punctuation]%}$char_372%{$reset_color%}"
   PS2="> "
Index: Functions/Prompts/prompt_fade_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_fade_setup,v
retrieving revision 1.2
diff -u -r1.2 prompt_fade_setup
--- Functions/Prompts/prompt_fade_setup	10 May 2005 04:39:02 -0000	1.2
+++ Functions/Prompts/prompt_fade_setup	14 Jun 2007 15:46:24 -0000
@@ -14,8 +14,8 @@
 default colors are green, white, and white.  This theme works best
 with a dark background.
 
-Recommended fonts for this theme: nexus or vga or similar.  If you
-don't have any of these, the 8-bit characters will probably look
+Recommended fonts for this theme: either UTF-8, or nexus or vga or similar.
+If you don't have any of these, the 8-bit characters will probably look
 stupid.
 EOH
 }
@@ -27,9 +27,9 @@
   local userhost=${2:-'white'}
   local date=${3:-'white'}
 
-  for code in 333 262 261 260; do
-    local char_$code=$(echo -n "\\0$code")
-  done
+  local char_333 char_262 char_261 char_260
+  autoload -U prompt_special_chars
+  prompt_special_chars
 
   PS1="%{$fg[$fadebar_cwd]$bg[$fadebar_cwd]$bold_color%}$char_333$char_262$char_261$char_260%{$fg[$userhost]$bg[$fadebar_cwd]$bold_color%}%n@%m%{$reset_color$fg[$fadebar_cwd]$bg[grey]%}$char_333$char_262$char_261$char_260%{$fg[$date]$bg[grey]$bold_color%} %D{%a %b %d} %D{%I:%M:%S%P} $prompt_newline%{$fg[$fadebar_cwd]$bg[grey]$bold_color%}%~/%{$reset_color%} "
   PS2="%{$fg[$fadebar_cwd]$bg[grey]%}$char_333$char_262$char_261$char_260%{$reset_color%}>"
Index: Functions/Prompts/prompt_fire_setup
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Prompts/prompt_fire_setup,v
retrieving revision 1.2
diff -u -r1.2 prompt_fire_setup
--- Functions/Prompts/prompt_fire_setup	10 May 2005 04:39:02 -0000	1.2
+++ Functions/Prompts/prompt_fire_setup	14 Jun 2007 15:46:24 -0000
@@ -15,8 +15,9 @@
 The default colors are yellow, yellow, red, white, white, and yellow.
 This theme works best with a dark background.
 
-Recommended fonts for this theme: nexus or vga or similar.  If you
-don't have any of these, the 8-bit characters will probably look stupid.
+Recommended fonts for this theme: either UTF-8, or nexus or vga or similar.
+If you don't have any of these, the 8-bit characters will probably look
+stupid.
 EOH
 }
 
@@ -28,9 +29,9 @@
   local date=${5:-'white'}
   local cwd=${6:-'yellow'}
 
-  for code in 333 262 261 260; do
-    local char_$code=$(echo -n "\\0$code")
-  done
+  local char_333 char_262 char_261 char_260
+  autoload -U prompt_special_chars
+  prompt_special_chars
 
   local GRAD1="%{$char_333$char_262$char_261$char_260%}"
   local GRAD2="%{$char_260$char_261$char_262$char_333%}"
Index: Functions/Prompts/prompt_special_chars
===================================================================
RCS file: Functions/Prompts/prompt_special_chars
diff -N Functions/Prompts/prompt_special_chars
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Functions/Prompts/prompt_special_chars	14 Jun 2007 15:46:24 -0000
@@ -0,0 +1,18 @@
+# Utility function to set up some special characters
+# used by prompts.
+#
+# These used to be defined to characters found in particular
+# character sets (e.g. IBM852) which now aren't widely used.
+# We still provide them in that form if the current character
+# set isn't UTF-8.  We could in principle use iconv if available.
+
+if [[ ${LC_ALL:-${LC_CTYPE:-$LANG}} = *UTF-8* ]]; then
+  char_333=$'\xe2\x96\x88'
+  char_262=$'\xe2\x96\x93'
+  char_261=$'\xe2\x96\x92'
+  char_260=$'\xe2\x96\x91'
+else
+  for code in 333 262 261 260; do
+    char_$code=$(echo -n "\\0$code")
+  done
+fi


-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



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