tmux-logging icon indicating copy to clipboard operation
tmux-logging copied to clipboard

ansi and control code filtering

Open hack-char opened this issue 2 years ago • 3 comments

I am using Kali rolling, and the default ansi and control code filtering doesn't seem to work well. Doing the following seems to provide the best log review experience: Do not install ansi-filter Comment out the sed line trying to remove ansi/control codes in .tmux/plugins/tmux-logging/scripts/start_logging.sh

pipe_pane_sed() {
)"      local ansi_codes="(\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]|
#       tmux pipe-pane "exec cat - | sed -r 's/$ansi_codes//g' >> $FILE"
        tmux pipe-pane "exec cat - >> $FILE"
}

To review log files use 'ansi2txt' (from 'colorized-logs' package):

ansi2txt < ./tmux-ansifilter-test-3-0-0-20230628T123947.log| less

this leaves a few things like '^M' and '^G' in the display, but makes the log more understandable and complete in my opinion Might be best to incorporate ansi2txt into start_logging.sh but I haven't tried that

hack-char avatar Jun 28 '23 18:06 hack-char

I worked with pipe-pane and the output was awful. Some day I wrote a little Asciinema wrapper to record all my sessions. That works quite good 😊

cmprmsd avatar Jul 08 '23 07:07 cmprmsd

Thank you so much hack-char. Spent the past 3 hours stuck on this issue, and your solution worked. Thought I was going to lose my mind!

daven-sharma avatar Dec 12 '23 20:12 daven-sharma

I'm also using Kali Linux and had additional problems with backspace characters in my log. So I also installed colorized-logs and replaced the pipe_pane_sed() function in ~/.tmux/plugins/tmux-logging/scripts/start_logging.sh with:

pipe_pane_sed() {
	tmux pipe-pane "exec cat - | ansi2txt | col -b >> $FILE"
}

Now my logs look great. Thanks for your input @hack-char!

jwohlleben avatar Mar 07 '24 10:03 jwohlleben