Skip to content

Instantly share code, notes, and snippets.

@hoggren
Last active December 22, 2019 12:02
Show Gist options
  • Save hoggren/ebd49a55cb4a79786d12a025f50e030e to your computer and use it in GitHub Desktop.
Save hoggren/ebd49a55cb4a79786d12a025f50e030e to your computer and use it in GitHub Desktop.
Short description about the PSReadLine Module
# To scope this to your account, copy-paste the content below
# to `%USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1`.
# Create the file if it doesn't exists.
#PSReadline
# Remove the annoying warning/error sound and enable Emacs mode, it changes `Tab` completion behaviour, and much more:
# <https://docs.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-6>
Set-PSReadLineOption -EditMode Emacs -BellStyle None
# Binds `Shift-Tab` to "intellisense" to see all flags (ex. `-File` or `-Debug`)
# and allows you to select a flag using the arrow keys
Set-PSReadLineKeyHandler -Function MenuComplete -Key "Shift-Tab"
# Shows your last 500 commands in a graphical window
function HistoryWindow {
$tail = 500
[string[]]$history = Get-Content (Get-PSReadLineOption).HistorySavePath -Tail $tail
[Array]::Reverse($history)
$history | Select-Object -unique | Out-GridView -Title "PowerShell Command History" -OutputMode Single
}
# Set custom prompt
function prompt {
(Get-Date).ToString("[HH:mm:ss] ") + "$(Get-Location)`n♯ "
# "$env:USERNAME at $env:USERDOMAIN in $(Get-Location)`nλ "
# "$env:USERNAME at $env:USERDOMAIN in $(Get-Location)`n♯ "
# "$env:USERDOMAIN\$env:USERNAME in $(Get-Location)`nλ "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment