3

Powershell 修改提示符的文字内容和颜色

 2 years ago
source link: https://www.lfhacks.com/tech/powershell-prompt-customization
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Powershell 修改提示符的文字内容和颜色

扫一扫,用手机分享 qr.php?ACMBMVBtVyRUdlEgWysHbFAvXnEBeA0kBSILLVVvAmJTbQ1hVWNSPlN2UX4DYwQ6UG1XeFQuATpTYA5uAHlUIgA5AXtQYFciVHFROFs9BzpQbF5zAX8NIQU6C25VcwJwUygNY1V1UiZTcVE%2FA20EPFB6VzZULgE2U2wOaABwVCYAawE9UDNXYlQ7UWhbawdlUDJebQE%2F
951.jpg

PowerShell 自带的提示符不够美观,影响工作效率。本文介绍一种自定义 PowerShell 命令提示符的方法。

作为从 Mac 的 iTerm 迁移到 Windows 的用户,我个人喜欢简单风格的提示符。类似下面这种:

所以当使用上 PowerShell 后,我自然也希望能延续相同的风格。类似下面这种:

上图就是我改造 PowerShell 提示符的效果。下面介绍如何实现这种效果。

ps1 文件

ps1 文件类似 linux 的 .profile 文件,在 shell 初始化时会预先执行。在 Powershell 中, ps1 文件的路径保存在 $Profile 变量中,输入 echo $Profile 命令能看到它的绝对路径:

如果是第一次使用 Powershell ,这个文件并不存在,需要你手动创建,输入 notepad $Profile 命令用记事本打开。


坚持原创不易。如果您觉得有收获,请考虑资助本站,以期待更多原创文章。

打赏作者,支持小站

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK