在 Cygwin 中如何更改字体颜色?
我想开始使用 Cygwin,但我对字体颜色不满意,想将其更改为黑色背景的浅绿色。
(顺便说一句,我尝试谷歌搜索但无济于事)
I want to start using Cygwin, but I am not pleased with the font color and would like to change it to light green with a black background.
(I tried googling to no avail BTW)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
它基本上只是一个 DOS 窗口。 因此,单击 shell 窗口左上角的图标即可获取菜单。 转到属性。 然后,您可以更改颜色、字体、命令历史记录和编辑选项(您将需要打开快速编辑和插入模式)。
It is basically just a DOS window. So click on the icon in the upper left of the shell window to get the menu. Go to properties. You can then change the colors, font, command history, and edit options (you will want to turn on Quick Edit and Insert modes).
我自己发现标准 shell 非常糟糕。
我下载并安装 rxvt 软件包并更改 cygwin.bat 以启动 rxvt,它对复制剪切粘贴有更好的支持。
-e 和 -login 将启动 shell 切换到 rxvt 以及其余的:
-fn 设置 courier 大小 16 字体(告我吧)
-sl 滚动行数为 9999
黑色背景和青色前景
选择文本将自动填充粘贴缓冲区
最后一位 (-e /bin/bash -login) 启动 bash 并告诉它它是一个运行配置文件设置等的登录 shell。
I find the standard shell to be pretty horrible myself.
I download and install the rxvt package and change the cygwin.bat to launch rxvt which has nicer support of copy-cut-n-paste.
The -e and -login switch the launch shell to the rxvt one and the rest:
-fn sets a courier size 16 font (sue me)
-sl scroll lines of 9999
Black background and Cyan foreground
selecting text will fill the paste buffer automatically
the last bit (-e /bin/bash -login) launches bash and tells it that its a login shell which runs the profile setups and such.
如果您想要一个比 Windows 命令行窗口更好的终端与 cygwin 一起使用,您可以从 cygwin 中启动
xterm
,或者查看使用 puttycyg,它是 Windows ssh 客户端 putty 的修补版本,旨在与本地 cygwin 安装一起使用(除了正常的 ssh 功能之外)。 puttycyg 应该为您提供比 Windows 命令行窗口更好的终端控制。If you want a better terminal to use with cygwin than the Windows Command Line window you could start
xterm
from within cygwin, or look at using puttycyg, which is a patched version of the windows ssh client putty designed to work with a local cygwin installation (in addition to the normal ssh functionality). puttycyg should provide you with much better control of your terminal than the Windows Command Line window.虽然其他人建议使用不同的终端,但默认的 Cygwin 终端仿真器 (mintty) 允许您自行更改颜色。 您可以通过选项对话框更改前景色、背景色和光标颜色。 您可以通过单击上下文菜单(窗口左上角的图标)找到选项对话框。
其余的 ANSI 颜色只能从配置文件 (
~/.minttyrc
) 更改。 不幸的是,此文件的参考确实不包含示例,因此需要一些猜测。 您可以在 github 上找到我的示例。 我只增加了蓝色的亮度。 还有一个存储库,其中包含一个存储库。 com/mavnn/mintty-colors-solarized/blob/master/.minttyrc.light" rel="noreferrer">light 和 深色 solarized 主题。 您可以使用这些来获取灵感。顺便说一句,在我的例子中,更改 Blue 的定义似乎没有改变任何事情,但更改 BoldBlue 改变了粗体和默认变体。 我花了一段时间才弄清楚这一点...我不断地更改
Blue
并且因为没有发生任何事情,我被其他细节转移了注意力(例如:Term=xterm- 256color
& co)...也许我读的文档不适用于我正在运行的同一 Cygwin 版本。 当你摆弄你的主题时,你应该记住这一点。编辑文件后,关闭并重新打开 Cygwin 终端,新的颜色应该会显示。
哦...对于您最初的请求(黑底绿),您唯一需要的是:
但是您应该考虑将默认前景色保留为白色(或浅灰色),除非您将全部更改为还有其他颜色代码! 某些应用程序打印彩色输出,并且您不会看到“绿色”,因为其他所有内容也是绿色的:)但是,Cygwin 中绿色的默认颜色是
rgb:0,191,0 code>,所以如果您使用其他东西(例如提到的
rgb:0,255,0
),您至少会看到亮度的差异。While others suggest to use a different terminal, the default Cygwin terminal emulator (mintty) lets you change the colors itself. You can change the foreground, background and cursor colors via the options dialog. You can find the options dialog by clicking on the context menu (the icon in the upper left of the window).
The remaining ANSI colors can only be changed from the config file (
~/.minttyrc
). Unfortunately the reference for this file does not contain an example, so a bit of guesswork is needed. You can find my example over on github. I only increased the brightness for blue. There is also a repo which contains the light and dark themes of solarized. You use these for inspiration.On a side-note, in my case it seemed that changing the definition of
Blue
did not change a thing, but changingBoldBlue
changed both the bold and default variant. It took me a while to figure this out... I kept changingBlue
and because nothing was happening, I got side-tracked by other details (f.ex.:Term=xterm-256color
& co)... Maybe the docs I read are are not for the same Cygwin version I am running. You should keep this in mind when fiddling around with your theme.After editing the file, close and re-open the Cygwin terminal and the new colors should show up.
Oh... and for your original request (green on black), the only thing you need is:
But you should consider keeping the default foreground colour to white (or light gray) unless you change all the other colour codes as well! Some application print colorised output, and you will not see "green", because everything else is green too :) However, the default color for green in Cygwin is
rgb:0,191,0
, so if you use something else (like the mentionedrgb:0,255,0
) you will at least see a difference in brightness.我建议使用 Console2。 这为您提供了一个选项卡式界面,您可以在其中同时拥有 Cygwin 选项卡和 Windows 命令提示符选项卡。 有很多自定义选项,以及更好的剪切和粘贴支持。
I'd recommend using Console2. This gives you a tabbed interface where you can have both Cygwin tabs and Windows Command prompt tabs. There's lots of customisation options, and much better cut and paste support.
cygwin 图标实际上只是一个 MS-DOS 批处理文件(如果右键单击它,可以对其进行编辑,并看到它只是从 cygwin\bin 目录启动 bash)。 如果右键单击并转到“属性”,则会出现一个“颜色”选项卡,您可以在其中更改背景和字体颜色。 如果您修改主要快捷方式属性,则每次都会使用这些属性启动。
The cygwin icon is actually just a MS-DOS batch file (if you right-click on it, you can edit it and see that it just launches bash from the cygwin\bin directory). If you right-click and go to Properties, there's a Colors tab where you can change the background and font colors. If you modify the main shortcut properties, it should launch with those every time.
我使用 Cygwin 的 rxvt 和 .Xdefaults 文件来调整
我的 cygwin.bat:
I use Cygwin's rxvt and an .Xdefaults file to tweak
My cygwin.bat:
rxvt 很棒,但我也对更改 cygwin 的 bash shell 的颜色感兴趣。
为了更改这些颜色,我编辑了 cygwin\etc\DIR_COLORS
并更改行
并重新配置我的 .bashrc,其中已
看到 http://cygwin .com/ml/cygwin/2001-05/msg00938.html
提示颜色也在
/etc/配置文件
例如,在我的登录 .bashrc 中将提示设置为黄色以覆盖 /etc/profile,我可以添加以下行
rxvt is great but I was also interested in changing the colors for cygwin's bash shell.
To change these colors I edited cygwin\etc\DIR_COLORS
and change the lines
and re-sourced my .bashrc which had
see http://cygwin.com/ml/cygwin/2001-05/msg00938.html
also the prompt color is in
/etc/profile
for example setting the prompt to yellow in my login .bashrc to override the /etc/profile, I can add the line
仅供您参考。 Cygwin不是终端(或控制台)应用程序。这类似于回答您正在使用 Windows 来询问您使用什么浏览器上网。 您可以在Windows上使用各种浏览器打开网站,例如Chrome、Opera、Firefox或MSIE。 类似地,您可以在各种终端中打开 Cygwin 的 shell。 终端是一个应用程序,它管理用户的输入和输出 - 从 Cygwin 的 shell 呈现文本输出并将用户的输入(键盘和鼠标)发送回它。 因此字体和颜色设置取决于您使用的终端。
Windows 有许多不同的终端应用程序。 列举其中一些:
ConEmu -我肯定会推荐这个,你可以通过多种方式配置它,它有选项卡等。
Console2 - 与之前的类似,但选项较少
MinTTY - 这个默认情况下随 Cygwin 一起安装,但它非常基本。 您应该在“开始”菜单中以“Cygwin Terminal”名称找到它。
Windows 控制台 - 您还可以使用普通 Windows 控制台:执行
cmd.exe
,导航到 Cygwin 的根目录并执行bin/bash.exe -- login -i
或Cygwin.bat
Just for your information. Cygwin is not a terminal (or console) application. It's similar to answer that you're using Windows to question in what browser do you surf the web. You can open website on Windows using various browsers, e.g. Chrome, Opera, Firefox or MSIE. Analogously you can open Cygwin's shell in various terminals. Terminal is an application, which manages input from and output to a user - renders text output from Cygwin's shell and sends user's input (keyboard and mouse) back to it. Therefore font and color settings depend on terminal you use.
There are a lot of various terminal applications for Windows. To name some of them:
ConEmu - I would definitely recommend this one, you can configure it in many ways, it has tabs etc.
Console2 - similar to the previous with less options
MinTTY - this one is installed with Cygwin by default, but it's very basic. You should find it in Start menu under the name "Cygwin Terminal".
Windows Console - you can also use plain Windows Console: execute
cmd.exe
, navigate to Cygwin's root directory and executebin/bash.exe --login -i
orCygwin.bat
CygWin 解释颜色的方法(无论是 shell、打印输出、提示...等)应该与任何其他 Linux 相同,但这里的问题来自于 Windows shell,它没有太多的功能。的能力。
好吧,我不知道这是否有帮助,但对我来说这是最好的解决方案,因为我喜欢 Putty 作为终端:
从 CygWin 内部安装 OpenSSH (SSHD) 包:< /p>
apt-cyg 更新
apt-cyg 安装 sshd
ssh-主机配置 --> [以管理员身份运行]
net start sshd
使用 Putty 连接到您的计算机(localhost) :
putty localhost
现在你应该有一个像样的 shell 能够解释颜色。
CygWin method for interpreting colors (whether be it the shell, printouts, prompt... etc) should be the same as any other Linux, but the problem here comes from the Windows shell, that has not much capabilities for that.
Well, I don't know if this could be of help, but for me this is the best solution since I love Putty as terminal:
Install OpenSSH (SSHD) package from inside CygWin:
apt-cyg update
apt-cyg install sshd
ssh-host-config --> [Run as admin]
net start sshd
Connect to your computer (localhost) with Putty:
putty localhost
Now you should have a decent shell capable of interpreting colors.