Skip to content

Instantly share code, notes, and snippets.

@yath

yath/winssh.pl

Created Jun 24, 2018
Embed
What would you like to do?
#!/usr/bin/perl
use strict;
use warnings;
use Term::Filter::Callback;
# SGR attributes to replacement value (or undef, if to be deleted).
my %sgrmap = (
map { $_ => undef } 40..47, # set background color
37 => 30, # white => black
97 => 90, # bright white => bright black
);
# filter an SGR string (1;2;3;4;...).
sub filter_sgr {
return join(";", map {
exists $sgrmap{$_} ? (
defined $sgrmap{$_} ? $sgrmap{$_} : ())
: $_
} split(";", $_[0]))
}
Term::Filter::Callback->new(callbacks => {
munge_output => sub {
my ($self, $text) = @_;
$text =~ s/\e\[([^m]+)m/"\e[".filter_sgr($1)."m"/ge;
$text;
},
})->run("ssh", @ARGV);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.