3

In my crontab, I reference a shell script, print-size, that contains the following lines.

#!/bin/sh
tmux new-session -t check-size -d
tmux send-keys -t check-size 'echo $COLUMNS $LINES' C-m

When this script executes as a cron job, it prints 80 23, apparently because the default terminal size is 80x24. If I execute this shell script from a terminal window, it prints the size of that terminal window (minus one line for tmux's status line).

Is there a way to influence the size of the tmux window so the above script will print something different, say 132 42, in a cron job?

If it matters, this is for Ubuntu 14.04 but I suspect the same behavior in any *nix.

1 Answer 1

1

Checking the source code is the way to go: tmux only looks at the system's notion of the size in check-size, and before that, when attaching to or creating a session, it starts with 24x80. The latter is configurable with the command-line -x and -y options.

The manual page lists this in new-session:

The new session is attached to the current terminal unless -d is given. window-name and shell-command are the name of and shell command to execute in the initial window. If -d is used, -x and -y specify the size of the initial window (80 by 24 if not given).

1
  • Yes, that's it, thank you. I was trying to set it after the fact with resize-pane which doesn't work since a pane cannot be larger than its enclosing window. Commented Jul 24, 2016 at 1:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .