From 8b21d59cfac518f3f7bd1a126c7e36459a5d7f84 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Mon, 4 Oct 1999 22:57:19 +0000 Subject: zsh-workers/8129 --- Misc/bash2zshprompt | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 Misc/bash2zshprompt (limited to 'Misc') diff --git a/Misc/bash2zshprompt b/Misc/bash2zshprompt new file mode 100644 index 000000000..aa0472ed1 --- /dev/null +++ b/Misc/bash2zshprompt @@ -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 + +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 \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/(?