$recording = 0;
$echo_text = "";
$command = "";

sub cmd_echo {
  chomp;
  $command = $_;
  $echo_text = "";
  $recording = 1;
  run($command);
} 

sub echo_grabber {

  if (!$recording) { 
    return 1; 
  }

  my $converted = $_;

  $converted =~ s/$BWhite/$col_W/g;
  $converted =~ s/$BRed/$col_R/g;
  $converted =~ s/$BGreen/$col_G/g;
  $converted =~ s/$BBlue/$col_B/g;
  $converted =~ s/$BMagenta/$col_M/g;
  $converted =~ s/$BYellow/$col_Y/g;
  $converted =~ s/$BCyan/$col_C/g;
  $converted =~ s/$White/$col_w/g;
  $converted =~ s/$Red/$col_r/g;
  $converted =~ s/$Green/$col_g/g;
  $converted =~ s/$Blue/$col_b/g;
  $converted =~ s/$Magenta/$col_m/g;
  $converted =~ s/$Yellow/$col_y/g;
  $converted =~ s/$Cyan/$col_c/g;

  $echo_text = ($echo_text ? "$echo_text%l$converted": "$converted");
}


sub echo_prompt {
  if (!$recording) {
    return 1;
  }

  run("${commandCharacter}chatall ${col_B}COMMAND[$col_G$command$col_B](%l$echo_text%l$col_B)$col_R");
  $recording = 0;
}

prompt_add(\&echo_prompt);
output_add(\&echo_grabber);
