配置个性化PowerShell Console Profile
来源:互联网 发布:国家电网公司网络大学 编辑:程序博客网 时间:2024/04/30 23:18
相信大家一定在网上看到过有很多人的PowerShell Console界面有个自己的个性化,而不是默认的千篇一律,今天我也来把我的Console界面做了一个个性化,其实在很多年前就已经是这样,只是今天再次拿出来做了一些改动,首先看一张运行图,如下:
是不是挺有个性?我们可以注意到最上边的标题栏目,包含了我在个人配置文件夹中的一些设置,有如下信息:
- 欢迎字符: Welcome Anders Back
- PowerShell的版本号
- Console界面也支持的行数识别
- 当前的运行路径显示
- Console界面的运行时间
- Console界面所占用的内存大小
代码如下:
$global:CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()function prompt{$host.ui.rawui.WindowTitle = "Welcome Anders Back --- " + "PowerShell" + " " + $Host.Version + " Line: " + $host.UI.RawUI.CursorPosition.Y `+ " --- Current Location: " + $(Get-Location) + " --- RuningTime: " + ((((Get-Date)-(Get-Process -id $pid).starttime) -as [string]) -split '\.')[0] `+ " --- Memory Utilization: " + $('{0:n2}' -f ([double](Get-Process -Id $pid).WorkingSet/1MB)) + "MB"$Line=$host.UI.RawUI.CursorPosition.Y Write-Host ("[^_^]") -NoNewline -ForegroundColor GreenWrite-Host ("PS") -NoNewline -ForegroundColor RedWrite-Host "[$Line]>" -NoNewline -ForegroundColor Yellow return " "}
以上6个功能其实非常简单,但是其中3点我们要在这里简单说明下原理,3、行数识别以及5、运行时间,6、所占内存大小
关于行数识别,我们使用的是$host.UI.RawUI.CursorPosition.Y类型属性下的Y轴来判断的。而运行时间则是使用获取Conosole进程的开始时间与当前时间的差值所计算得出,最后的内存占用则依然是使用Console进程的WorkingSet属性计算得出。
是不是非常简单,有个性!:)
0 0
- 配置个性化PowerShell Console Profile
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- ASP.NET 2.0个性化配置(profile)
- 嵌入式 linux下网络质量测试工具ipref工具小结
- 分享比较全的教程
- 让jquery变高效的小秘密
- 经纬财富:北海现货白银(天通银)与纸白银之间的区别与联系
- Yahoo!团队:网站性能优化的35条黄金守则
- 配置个性化PowerShell Console Profile
- Linux 运行程序时找不到so文件
- Filter系列二
- 【中英】mac电脑清理软件 ToolWiz Mac Boost
- 日期专题
- vim对一个文件的批处理script
- XAMPP配置域名
- 苹果新的编程语言 Swift 语言进阶(十一)--实例的初始化与类的析构
- Linux分区问题汇总