Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansi and control code filtering #67

Open
hack-char opened this issue Jun 28, 2023 · 3 comments
Open

ansi and control code filtering #67

hack-char opened this issue Jun 28, 2023 · 3 comments

Comments

@hack-char
Copy link

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
Copy link

cmprmsd commented Jul 8, 2023

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
Copy link

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
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants