Skip to content

Instantly share code, notes, and snippets.

@jhclark
Last active November 9, 2017 18:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhclark/ad3de4b0ba998a8e9e7050ee07210ed5 to your computer and use it in GitHub Desktop.
Save jhclark/ad3de4b0ba998a8e9e7050ee07210ed5 to your computer and use it in GitHub Desktop.
Quick configure powershell (PSReadline + other goodies)
# 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