-1

When I PuTTy in, I typically: "stty rows 48 columns 240" after login.

  • I'm after a single-line/entry, in .profile or .bashrc or even grub.cfg to hard-set stty cols/rows
  • If this requires a script, I can work with the links below.
  • If there's a direct solution I'd like to find it.

Addendum

  • Xterm is not installed
  • PuTTy connection is into Host
  • Virsh console is then used to connect to VM
  • Looking to set/adjust the rows/cols on the VM when I log in with my profile
  • When I connect, my "PuTTy->Window->Size->Columns/Rows" are preset to the values I'm after. This setting does not resize the VM's Col/Row size.
  • Hence the need for "stty rows 48 columns 240" after login <- which I am trying to eliminate

Resize/reset discussed at great length:

  • The question does not explain what is wrong with using the command that is in the very first sentence of the question. – JdeBP Jul 18 at 16:42
2

The resize program can do this for you:

resize -s rows cols

or for your example

resize -s 48 240

This is a feature of xterm which PuTTY happens to recognize (it can be disabled in the Terminal / Features menu, but is normally enabled).

There's a possible terminfo capability which could be set up, but it is used unconditionally by GNU screen and would be a nuisance. So we don't add that capability to the terminal description.

The feature used is documented in XTerm Control Sequences:

CSI Ps ; Ps ; Ps t
Window manipulation (XTWINOPS), dtterm, extended by xterm. These controls may be disabled using the allowWindowOps resource.

The first Ps is here:

Ps = 8 ; height ; width ⇒ Resize the text area to given height and width in characters. Omitted parameters reuse the current height or width. Zero parameters use the display's height or width.

Some of the background for the window-manipulation feature is documented in the Miscellaneous section.

For your example, you could hardcode it like this:

printf '\033[8;%d;%dt' $height $width

Whether you are using resize or just a printf, PuTTY will resize its window, sending a SIGWINCH via the connection which will update the terminal's size—just as if you had issued a stty command.

However... if you're using a serial line, that SIGWINCH goes nowhere. resize is unaffected, since it is designed to handle this case.

| improve this answer | |
  • I appreciate the answer Thomas. I'm trying to hard-set/configure these values in a scenario where xterm is not installed. Where.. the cols/rows need to be redefined... but redefined to predetermined values, not the actual screen size. – Gus.Gilliland Jul 18 at 15:12
  • Could you add that to your question? It's valuable context to help with finding an answer for you, @Gus – roaima Jul 18 at 21:37
  • If OP needs stty settings that don't match the actual screensize, that would be a rather unusual case. – Thomas Dickey Jul 18 at 22:15
  • Addendum added. I don't want or need the end machine to query my window size. I have my window size pre-configured in PuTTy and it's the only PC I connect from. I want the VM to recognize, that when it's me logging in, I want a predefined col/row setting to be used. – Gus.Gilliland Jul 19 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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