Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux capture-pane doesn't print all texts properly but inserts newline after a few characters instead

Tags:

linux

bash

tmux

I have this script here:

tmux send-keys "${@:1}" Enter
sleep 2.5; tmux capture-pane -p -S -32767

This script captures the tmux pane and prints the output. I noticed that if the tmux pane isn't opened, the output would look like this:

L 05/15/2018 - 16:07:43
: "thebravelittleMercen
ary<348><[U:1:313493299
]><Blue>" say "!resizem
ytorso"
BOI: !resizemyhands
L 05/15/2018 - 16:07:44
: "BOI<377><[U:1:453920
082]><Red>" say "!resiz
emyhands"

In reality, it should look like this:

L 05/15/2018 - 16:07:43: "thebravelittleMercenary<348><[U:1:313493299]><Blue>" say "!resizemytorso"
BOI: !resizemyhands
L 05/15/2018 - 16:07:44: "BOI<377><[U:1:453920082]><Red>" say "!resizemyhands"

It is worth mentioning that when I do tmux attach and capture the pane, the output lines have the same length as my console width: http://i.cubeupload.com/Rp1BEU.png

like image 851
diamondburned Avatar asked Sep 06 '25 03:09

diamondburned


1 Answers

The output is "wrapped" in the pane, so you'll want to use:

capture-pane -J

-J joins wrapped lines and preserves trailing spaces at each line's end.

↳ https://docs.oracle.com/cd/E86824_01/html/E54763/tmux-1.html

like image 164
l'L'l Avatar answered Sep 09 '25 02:09

l'L'l