about summary refs log tree commit diff
path: root/Misc/bash2zshprompt
diff options
context:
space:
mode:
Diffstat (limited to 'Misc/bash2zshprompt')
-rw-r--r--Misc/bash2zshprompt17
1 files changed, 10 insertions, 7 deletions
diff --git a/Misc/bash2zshprompt b/Misc/bash2zshprompt
index aa0472ed1..7fc11434e 100644
--- a/Misc/bash2zshprompt
+++ b/Misc/bash2zshprompt
@@ -10,7 +10,7 @@ use strict;
 my @colours = qw/grey red green yellow blue magenta cyan white/;
 
 my @codes = ();
-my %bold;
+my %boldp;
 my $out = '';
 
 print "# Converted to zsh prompt theme by bash2zshprompt, written by <adam\@spiers.net>\n";
@@ -25,7 +25,7 @@ while (<>) {
   # UGH
   elsif (! $seen_fn_end && $seen_fn) {
     s/^\s*/  /;
-    s/^\s*}\s*$/\n  precmd () { }\n  preexec () { }\n}\n/ and $seen_fn_end++;
+    s/^\s*}\s*$/\n  precmd () { setopt promptsubst }\n  preexec () { }\n}\n/ and $seen_fn_end++;
   }
 
   s/\\\[/%{/g;
@@ -44,6 +44,8 @@ while (<>) {
   s/(?<!\\)\\#/%!/g; # hmmm
   s/(?<!\\)\\n/\$prompt_newline/g;
   s/(?<!\\)\\s/\$SHELL/g;
+  s/(?<!\\)\\v/\$ZSH_VERSION[1]/g;
+  s/(?<!\\)\\V/\${ZSH_VERSION%%-*}/g;
   s/(?<!\\)\\w/%~/g;
   s/(?<!\\)\\W/%1~/g;
   s/(?<!\\)\\\$(?!\()/%\#/g;
@@ -78,21 +80,22 @@ sub color {
               ($p[1] eq '4') ? 'bg' :
               '???');
 
-  $bold{$fgbg} ||= '';
+  $boldp{$fgbg} ||= '';
 
   if ($p[0] =~ /^0?0$/) {
-    $bold{$fgbg} = '';
+    $boldp{$fgbg} = '';
     return '$reset_color';
   }
   
   if ($p[0] =~ /^0?1$/) {
-    $bold{$fgbg} = 'bold_';
+    $boldp{$fgbg} = 'bold_';
     return '$bold_color';
   }
 
   return '$' .
-         "${fgbg}_$bold{$fgbg}" .
-         $colours[$p[2]];
+         "${fgbg}$boldp{$fgbg}\[" .
+         $colours[$p[2]] .
+         ']';
 }
 
 sub split_codes {