使用命令提示符修改 cmd.exe 属性
这不是很好的递归吗?
我的外部驱动器上有一个便携式命令提示符,它有一个很好的 .bat 文件来配置一些初始设置,但我想要更多!
以下是我知道如何从 .bat 设置的内容:
- Colors = (color XY) 其中 x 和 y 是预定义颜色的十六进制数字
- Prompt = (prompt $p$g) 将提示设置为“C:\etc\etc >” ” 默认提示
- Title = (title "text") 设置窗口标题为 "text"
- Screen Size = (mode con: cols=XXlines=YY) 设置窗口的列和行大小
- Path = (SET PATH=%~ d0\bin;%PATH%) 设置我的工具的本地路径并附加计算机的路径
所以这一切都很棒。 但有一些设置我似乎无法从蝙蝠中设置。 比如,如果不使用“属性”对话框,我将如何设置这些:
- 缓冲区 = 不是屏幕大小,而是缓冲区
- 选项,例如快速编辑模式和自动完成
- 弹出颜色
- 字体。 您可以在便携式驱动器上使用字体吗?还是必须安装它才能工作?
- 命令历史选项
Isn't that nicely recursive?
I've got a portable command prompt on my external drive, and it has a nice .bat file to configure some initial settings, but I'd like more!
Here's what I know how to set from .bat:
- Colors = (color XY) where x and y are hex digits for the predefined colors
- Prompt = (prompt $p$g) sets the prompt to "C:\etc\etc >" the default prompt
- Title = (title "text") sets the window title to "text"
- Screen Size = (mode con: cols=XX lines=YY) sets the columns and lines size of the window
- Path = (SET PATH=%~d0\bin;%PATH%) sets up local path to my tools and appends the computer's path
So that's all great. But there are a few settings I can't seem to set from the bat. Like, how would I set these up wihtout using the Properties dialogue:
- Buffer = not screen size, but the buffer
- Options like quick edit mode and autocomplete
- Popup colors
- Font. And can you use a font on the portable drive, or must it be installed to work?
- Command history options
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
关于设置缓冲区大小:
使用
mode con: cols=XXlines=YY
不仅设置窗口(屏幕)大小,还设置缓冲区大小。如果您根据可用的屏幕尺寸指定系统允许的尺寸,您将看到窗口和缓冲区尺寸都设置为相同的值; 例如:
结果如下(值相同):
相比之下,如果您根据可用屏幕尺寸指定太大的值,您会看到窗口尺寸更改为最大值,但缓冲区大小更改为指定的值。
屏幕分辨率为 1280x1024 时,您将得到:
Regarding setting the buffer size:
Using
mode con: cols=XX lines=YY
sets not only the window (screen) size, but the buffer size too.If you specify a size allowed by your system, based on available screen size, you'll see that both window and buffer dimension are set to the same value; .e.g:
results in the following (values are the same):
By contrast, if you specify values that are too large based on the available screen size, you'll see that the window size changes to its maximum, but the buffer size is changed to the values as specified.
With a screen resolution of 1280x1024, you'll get:
您可以通过快捷方式(.INK 文件)设置这些值。
我的桌面上有一个以此为目标的快捷方式:
%windir%\system32\cmd.exe /K %userprofile%\STARTUP.CMD
/K 开关告诉 CMD.exe 运行批处理文件(它设置一些变量,提示等),然后保持打开状态。
如果右键单击快捷方式并查看其属性,您可以设置窗口和缓冲区大小、弹出颜色、起始位置(x、y 轴)等。这些设置将保存在快捷方式本身中,并且每次都会应用当您使用该快捷方式打开 CMD.exe 时。
You can set these values through a shortcut (.INK file).
I have a shortcut on my desktop with this as the target:
%windir%\system32\cmd.exe /K %userprofile%\STARTUP.CMD
The /K switch tells CMD.exe to run the batch file (which sets some variables, the prompt, etc.) and then stay open.
If you right-click on the shortcut and view its properties, you can set the window and buffer size, popup colors, starting position (x,y axis), etc. The settings will be saved in the shortcut itself and will be applied every time you open CMD.exe using that shortcut.
关于自动完成:
在那里找不到任何命令历史记录选项( cmd /? ),并且您询问的其他选项似乎是通过注册表设置专门设置的。
Regarding auto-completion:
Couldn't find any command history options in there ( cmd /? ), and it looks like the other options you asked about are set exclusively through registry settings.
要真正调整缓冲区大小,请使用 DOSKEY /LISTSIZE=size
自从 Microsoft 从命令/cmd 提示符中取出 ANSI ESC 控制后,您就无法再在 shell 中更改颜色了。
For true Buffer Size adjustment use DOSKEY /LISTSIZE=size
You can't change colors within the shell anymore since Microsoft took ANSI ESC control out of the command/cmd prompts.