tmux-plugins / tmux-logging

Easy logging and screen capturing for Tmux.
MIT License
1.03k stars 113 forks source link

ansi and control code filtering #67

Open hack-char opened 1 year ago

hack-char commented 1 year ago

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

cmprmsd commented 1 year ago

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 😊

daven-sharma commented 9 months ago

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!

jwohlleben commented 6 months ago

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!