Last active
June 2, 2017 12:37
-
-
Save nirlanka/63b319d99a12e12de8b95e14e442757c to your computer and use it in GitHub Desktop.
Cooler PowerShell Prompt (code for blog article)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clear-Host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new-item alias:np -value C:\Windows\System32\notepad.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new-item -itemtype file -path $profile -force | |
notepad $PROFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Shell = $Host.UI.RawUI | |
$size = $Shell.WindowSize | |
$size.width=70 | |
$size.height=25 | |
$Shell.WindowSize = $size | |
$size = $Shell.BufferSize | |
$size.width=70 | |
$size.height=5000 | |
$Shell.BufferSize = $size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$shell.BackgroundColor = “Gray” | |
$shell.ForegroundColor = “Black” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set-location e:\dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Prompt | |
{ | |
$id = 1 | |
$historyItem = Get-History -Count 1 | |
if($historyItem) | |
{ | |
$id = $historyItem.Id + 1 | |
} | |
Write-Host -ForegroundColor Green -NoNewLine "$id " | |
Write-Host -ForegroundColor Gray -NoNewLine "$(Get-Location) " | |
$host.UI.RawUI.WindowTitle = "PS $(Get-Location)" | |
"$ " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment