Skip to content

Instantly share code, notes, and snippets.

@ivorpad
Created February 13, 2026 06:20
Show Gist options
  • Select an option

  • Save ivorpad/01e1397a296c9d5dfb0d719c53b11211 to your computer and use it in GitHub Desktop.

Select an option

Save ivorpad/01e1397a296c9d5dfb0d719c53b11211 to your computer and use it in GitHub Desktop.
tmux-clean: Perl filter to strip TUI chrome from tmux capture-pane output (ANSI, box-drawing, Claude Code UI)
#!/usr/bin/env perl
use utf8;
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
my $blank = 0;
while (<STDIN>) {
# strip ANSI escape sequences
s/\e\[[0-9;]*[a-zA-Z]//g;
s/\e\][^\a]*\a//g;
# strip Unicode decorative ranges
s/[\x{2500}-\x{257F}]//g; # box drawing
s/[\x{2580}-\x{259F}]//g; # block elements
s/[\x{2800}-\x{28FF}]//g; # braille
s/[\x{25A0}-\x{25FF}]//g; # geometric shapes
s/[\x{2700}-\x{27BF}]//g; # dingbats
s/[\x{E000}-\x{F8FF}]//g; # private use area
s/[\x{00}-\x{08}\x{0B}\x{0C}\x{0E}-\x{1F}\x{7F}]//g;
s/[\x{80}-\x{9F}]//g;
s/[╭╮╰╯║═╔╗╚╝╠╣╦╩╬]//g;
s/[▐▛▜▌▝▖▘▗▙▟⏵◯✳⏺❯]//g;
# skip status/chrome lines
next if /bypass permissions|shift\+tab to cycle/i;
next if /^\s*[\w-]+ \| (?:Opus|Sonnet|Haiku).*$/;
next if /^\s*\/ide for/;
next if /^\s*Claude Code v[\d.]+\s*$/;
next if /^\s*Welcome back/;
next if /^\s*Tips for getting started/;
next if /^\s*Run \/init to create/;
next if /^\s*Recent activity/;
next if /No recent activity/;
next if /^\s*Opus.*Claude Max\s*$/;
next if /^\s*~\/.*Documents\/Personal\s*$/;
# collapse blank lines
s/^\s+$//;
if (/^\s*$/) { print "\n" unless $blank++; next }
$blank = 0;
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment