#!/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 %boldp; 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 () { setopt promptsubst }\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/(?