andot / CoolCode

https://coolcode.org
2 stars 0 forks source link

PowerShell 美化指南 #3

Open andot opened 6 years ago

andot commented 6 years ago

https://coolcode.org/2018/03/16/how-to-make-your-powershell-beautiful/

samuelgaocn commented 6 years ago

你好,谢谢这么详细的介绍颜色控制方案,有个小问题,就是我的控制台显示这种字符 SamuelGao@DESKTOP-BLU878K  ~  能否发给我一份 更纱黑体Sarasa-Gothic 的ttf 格式的文件,谢谢 samuelgaocn@outlook.com

andot commented 6 years ago

@samuelgaocn 文章里面有更纱黑体的下载连接,可能不太明显,我再贴一遍吧。 https://github.com/be5invis/Sarasa-Gothic/releases

samuelgaocn commented 6 years ago

谢谢,这个编译太复杂了,我就不折腾了,又是xz格式文件,又是 otfcc, AFDKO and ttfautohint 。。。。。。

andot commented 6 years ago

你不需要自己编译啊,那个地址提供了 ttc 和 ttf 版本的字库下载。直接下载,解压缩,然后安装字体就可以了。

samuelgaocn commented 6 years ago

谢谢,我找到release了

Nomango commented 6 years ago

感谢博主分享!现在感觉 Powerline 也不是那么难用嘛哈哈哈哈哈

changhr2013 commented 6 years ago

用过之后所有命令行带 - 后面的参数颜色都变成透明的了,跟背景色融到一起了,求解救,还原都还原不回来了。。。

Nomango commented 6 years ago

@changhr2013

执行下面这几段代码,你的powershell高亮颜色就和博主一开始展示的图片一样了

Set-PSReadlineOption -TokenKind Command -ForegroundColor Blue
Set-PSReadlineOption -TokenKind Parameter -ForegroundColor Yellow
Set-PSReadlineOption -TokenKind Operator -ForegroundColor Yellow

其实不是高亮的颜色变了,是原来powershell的蠢蓝色变成黑色了

changhr2013 commented 6 years ago

@Nomango 解决了,万分感谢。

uuair commented 4 years ago

@changhr2013

执行下面这几段代码,你的powershell高亮颜色就和博主一开始展示的图片一样了

Set-PSReadlineOption -TokenKind Command -ForegroundColor Blue
Set-PSReadlineOption -TokenKind Parameter -ForegroundColor Yellow
Set-PSReadlineOption -TokenKind Operator -ForegroundColor Yellow

其实不是高亮的颜色变了,是原来powershell的蠢蓝色变成黑色了

··· Set-PSReadlineOption -TokenKind Command -ForegroundColor Blue Set-PSReadLineOption : 找不到与参数名称“TokenKind”匹配的参数。 所在位置 行:1 字符: 22

我执行完都是这个样子啊。。。

这个文章写得真好,让我初入win的人,有了很直接的改善,不过文章中有个小问题,在说到修改这里的时候,其实andot是用户名对吧?我当初忘记这个了,直接沾了命令过去,结果没法运行,不过这个还不是大问题,问题出在编辑下面这个文件时 C:\Users\andot\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

    U·pdate-DirColors ~/dircolors   

前面的目录是~/dir_colors吧。

uuair commented 4 years ago

对于新版的PSReadline取消了TokenKind参数,所以我找到了下面的表示方法: $colors = @{} $colors['Command'] = [System.ConsoleColor]::Blue $colors['Parameter'] = [System.ConsoleColor]::Yellow $colors['Operator'] = [System.ConsoleColor]::Yellow Set-PSReadLineOption -Colors $colors 希望对后来的人有帮助。

Nomango commented 4 years ago

@uuair 是的,ps更新居然不向下兼容,可以简写成下面的代码

Set-PSReadLineOption -Colors @{
    "Command"   = [ConsoleColor]::Blue
    "Parameter" = [ConsoleColor]::Yellow
    "Operator"  = [ConsoleColor]::Yellow
}
uuair commented 4 years ago

上个问题解决了,还是大佬厉害,简化的代码比我弄出来的好看多了。

再补充一点,就是因为CMD这个程序还存在,而且不可能不用,所以我查阅了一下资料,如果想美化CMD,可以选择修改注册表的方式,比如:https://github.com/neilpa/cmd-colors-solarized 看起来好像是powershell跟cmd一起修改,不过我怕好容易改完的不好恢复,所以没尝试。

DimonHo commented 3 years ago

image 请教这个地方的乱码该怎么解决? 以下是我powershell的配置,使用的是Fira Code的字体,也尝试过使用其它的字体,都没法解决这个地方的中文乱码问题。 image