先上效果图:
![](http://i0.hdslb.com/bfs/new_dyn/265c283377a9c321fced50422c678f7d386158857.png)
打开(或创建)C:\Users\【你的用户名】\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
,加入以下内容:
1 2 3 4 5 6 7 8 9 10 11 12
| function prompt { Write-Host -NoNewline "# " -ForegroundColor Blue Write-Host -NoNewline "$env:UserName" -ForegroundColor Cyan Write-Host -NoNewline " @ " Write-Host -NoNewline "$env:ComputerName" -ForegroundColor Green Write-Host -NoNewline " in " $path = "$pwd" -replace "C:\\Users\\【你的用户名】", "~" Write-Host -NoNewline "$path" -ForegroundColor Yellow $now = Get-Date -Format "tt hh:mm:ss" Write-Host " [$now]" return "$ " }
|
![](http://i0.hdslb.com/bfs/new_dyn/0757339bbfac1724bb7b06fc5907e2ed386158857.gif)