After saving data from a tmux session using capture-pane into a file.txt, the output can look like this:
PC1:/path$ cd /usr
PC1:/usr$ ll
total 0
drwxr-xr-x 1 root root 4096 May 21 2019 [1;34m.[0;39m/
drwxr-xr-x 1 root root 4096 Aug 1 2019 [1;34m..[0;39m/
drwxr-xr-x 1 root root 4096 Mar 17 15:09 [1;34mbin[0;39m/
drwxr-xr-x 1 root root 4096 Apr 12 2016 [1;34mgames[0;39m/
drwxr-xr-x 1 root root 4096 Feb 8 09:44 [1;34minclude[0;39m/
drwxr-xr-x 1 root root 4096 Feb 8 09:44 [1;34mlib[0;39m/
drwxr-xr-x 1 root root 4096 Nov 26 14:52 [1;34mlocal[0;39m/
drwxr-xr-x 1 root root 4096 May 21 2019 [1;34msbin[0;39m/
drwxr-xr-x 1 root root 4096 Feb 8 09:44 [1;34mshare[0;39m/
drwxr-xr-x 1 root root 4096 May 21 2019 [1;34msrc[0;39m/
PC1:/usr$
If you try cat file.txt
, it displays correctly with colors. But transferring that data to xtermjs results in a distorted view:
https://i.sstatic.net/sH5YK.png
Various attempts have been made:
- Adjusting the columns and rows on Terminal options
- Using "xterm-addon-fit"
- Loading the file in different ways to avoid loss of information
- Experimenting with xterm-for-reacth package
- Testing vanilla JS solutions
Unfortunately, none of these approaches have resolved the issue. The main goal now is to find a way to display text from a tmux session accurately on xtermjs.
To witness the problem firsthand, check out this codesandbox.