3

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

3
  • 1
    Maybe try capture-pane -J...
    – l'L'l
    May 16, 2018 at 0:35
  • 1
    Oh that worked. I probably skipped through some important stuff in the manual May 17, 2018 at 0:02
  • In some manual pages the option is buried, so possibly not easy to find either :)
    – l'L'l
    May 18, 2018 at 4:41

1 Answer 1

8

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

1
  • On tmux 3.1c -J adds a bunch of trailing spaces to the end of most lines, seems to pad everything to 68 chars on a minimal terminal test with just echo a, so it's not ideal either. Apr 25, 2022 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.