Last active
November 9, 2017 18:33
-
-
Save jhclark/ad3de4b0ba998a8e9e7050ee07210ed5 to your computer and use it in GitHub Desktop.
Quick configure powershell (PSReadline + other goodies)
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
# Install | |
(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex | |
install-module psreadline | |
# One time use | |
import-module psreadline | |
Set-PSReadlineOption -EditMode Emacs | |
# Configure for use on every login | |
# First, make sure we're not going to clobber an existing profile... | |
cat $profile | |
"import-module psreadline; Set-PSReadlineOption -EditMode Emacs" > $profile | |
# Prompt | |
function global:Prompt { | |
write-host -NoNewline '[' | |
$time = "$(Get-Date -F 'HH:mm')" | |
write-host -NoNewline $time | |
write-host -NoNewline ' ' | |
write-host -NoNewline -fore Green "$env:username" | |
write-host -NoNewline '@' | |
write-host -NoNewline -fore Blue "$([System.Net.Dns]::GetHostName())" | |
write-host -NoNewline ' ' | |
# Resolve-Path will include the "provider" for UNC paths, so take that off using ProviderPath | |
# so that we don't get FileSystem::\\localhost\h$ | |
write-host -NoNewline "$(Get-PartialDirectory -Directory (Resolve-Path (Get-Location)).ProviderPath -Levels $PromptPathLevels)" | |
write-host -NoNewline '>' | |
return " " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment