用于更改 bash 窗口大小的 Bash 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5243445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash command to change size of bash window
提问by Dayanne
Is there any command to change size of bash window ( for example to set size on 150x90) ? I dont want to change .profile file.
是否有任何命令可以更改 bash 窗口的大小(例如设置 150x90 的大小)?我不想更改 .profile 文件。
回答by ephemient
Some (but not many) terminals accept the ANSI escape sequence
一些(但不是很多)终端接受 ANSI 转义序列
3[8;h;wt
(where \033
is the ASCII control character ESC
, and h
and w
are height and width in decimal).
(其中\033
是 ASCII 控制字符ESC
,h
和w
是十进制的高度和宽度)。
For example, in XTerm (afterallowing window ops through the Ctrl-RMB menu or the allowWindowOps
X resource),
例如,在 XTerm 中(通过 Ctrl-RMB 菜单或X 资源允许窗口操作后allowWindowOps
),
$ printf '3[8;40;100t'
will resize the window to 100x40 characters.
将窗口大小调整为 100x40 个字符。
回答by plhn
$ resize -s 90 150
see the file manual for more options.
有关更多选项,请参阅文件手册。
$ man resize
回答by pillpusher
The resize command works to change the size of the window, but you may experience some strange things if you don't also tell the terminal to use the whole area. This is what I use, and it works well.
resize 命令可以改变窗口的大小,但是如果你不告诉终端使用整个区域,你可能会遇到一些奇怪的事情。这是我使用的,并且效果很好。
#!/bin/bash
resize -s 33 100
stty rows 33
stty cols 100
回答by Bernhard
This is probably a question for https://superuser.com/, anyways, how do you launch your terminal window? Most of the terminal emulators have command line args to specify the size.
这可能是https://superuser.com/的问题,无论如何,您如何启动终端窗口?大多数终端模拟器都有命令行参数来指定大小。
Another option, if you need to change it after the window appeared wmctrl
might help you.
另一种选择,如果您需要在窗口出现后更改它wmctrl
可能会对您有所帮助。