Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Quick configure powershell (PSReadline + other goodies)
# Install
(new-object Net.WebClient).DownloadString("") | 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
You can’t perform that action at this time.