在cmd.exe和PowerShell中的PROMPT的颜色(只是PROMPT正确)? [英] Color for the PROMPT (just the PROMPT proper) in cmd.exe and PowerShell?

查看:584
本文介绍了在cmd.exe和PowerShell中的PROMPT的颜色(只是PROMPT正确)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以在Bash你只需配置 PS1 为你的提示添加颜色。我说的是正确的提示,而不是前景(文本)或背景的颜色。如果你需要在乱糟糟的文本输出中找到你的命令,它非常容易。



你可以实现相同的 cmd.exe ,或作为回退,PowerShell?一个彩色的提示?



我不知道是否可以在Win32之前的早期通过加载 ANSI.SYS 。我认为这只是使前景和背景丰富多彩。但我可能是错的。无论如何,那些日子已经走了,在我们现代的时代(我知道),我们使用 cmd.exe 或PowerShell。



我知道cmd.exe和PowerShell都能够输出彩色。对于cmd.exe,只需运行 color /?即可找到。但我的问题不是关于前台和背景,这是所有人类知道的 - 这只是改变cmd.exe的提示颜色,可能通过 PROMPT 环境变量通过Bash的 PS1 变量?可能吗?



不,Cygwin不是这个的替代品。我是一个Cygwin用户与MinTTY和所有,我喜欢它。但是我仍然希望我的 cmd.exe 提示也有颜色。

解决方案

点击此链接。有一个为CMD.exe shell开发的ANSI黑客



链接到ansi hack



我已经在我的win 7专业SP1上试过,


So in Bash you just configure PS1 to add colors to your prompt. I'm talking about the prompt proper, not the color of the foreground (text) or the background. And it's really easy in Bash and it helps a lot if you need to find your commands in a sea of messy text output.

Can you achieve the same for cmd.exe, or as a fallback, for PowerShell? A colored prompt?

I don't know if it could be done in the old days before Win32 by loading ANSI.SYS. I think that was just to make the foreground and the background colorful. But I might be wrong. And anyway, those days are gone, and in our modern times (I know), we're using cmd.exe, or PowerShell.

I know both cmd.exe and PowerShell are capable of colored output. For cmd.exe, just run color /? to find out. But my question is not about the foreground and the background, that's all known to humankind - it's about just changing the prompt color for cmd.exe, probably via the PROMPT environment variable as via the PS1 variable for Bash? Is it possible?

And no, Cygwin is not an alternative for this. I'm a Cygwin user with MinTTY and all, and I love it. But I still want my cmd.exe prompt colored, too.

解决方案

follow this link. There's an ANSI hack developped for the CMD.exe shell

link to ansi hack

I've tried it on my win 7 professional SP1 and works like a charm

这篇关于在cmd.exe和PowerShell中的PROMPT的颜色(只是PROMPT正确)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆