Reputation: 761
I'm using the pipe-pane of tmux to record what I was doing, and I want to parse and take a account of the commands I typed etc. But when I got the xxx.log
file, and opened it with vim, I found that there are many special word like ^H,^M,^G etc,see the sample:
administrator@ubuntu:~$ echo "hello,world[K[K[K[K[K[K[K[K[K[K"
h
administrator@ubuntu:~$ ^G^G^G^G
administrator@ubuntu:~$
I know that tmux records everything I typed, but some keys with Ctrl/alt prefix can not be displayed, and I want to ignore them. How can I archive that with perl/python or C, any tips?
Upvotes: 1
Views: 666
Reputation: 189936
In the general case, this is hard, because some programs make extensive use of display control codes to draw dialogs etc. If you just want to drop any individual unprintable characters, that's easy with tr
, but if you want to remove display control codes, too, that's significantly more complex, and basically requires knowledge about which terminal emulator you are working with. A plausible target would be xterm
but I'm not aware of any off-the-shelf solutions for stripping xterm
display codes.
Upvotes: 1