Skip to content

Instantly share code, notes, and snippets.

@margnus1
Last active August 29, 2015 14:08
Show Gist options
  • Save margnus1/bdb05761ffe75f98c68d to your computer and use it in GitHub Desktop.
Save margnus1/bdb05761ffe75f98c68d to your computer and use it in GitHub Desktop.
My PowerShell profile
Write-Host -NoNewline "Loading Posh-Git..."
[Console]::CursorLeft = 0
Import-Module posh-git
$Global:GitPromptSettings.BeforeText = "["
$Global:GitPromptSettings.AfterText = "] "
$Global:GitPromptSettings.UntrackedText = ""
$Global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::Red
$Global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Red
$Global:GitPromptSettings.ShowStatusWhenZero = false
$realLASTEXITCODE = $LASTEXITCODE
$env:GOPATH = "C:\Users\Magnus\go"
$env:GOGOROOT = "$env:GOPATH\src\github.com\mtornwall\gogo\priv" -replace "\\","/"
$env:CYGWIN = "nodosfilewarning"
$env:CC = "gcc"
function global:prompt {
$realLASTEXITCODE = $LASTEXITCODE
$gitStatus = Get-GitStatus
if ($gitStatus) {
Write-GitStatus $gitStatus
} else {
Write-Host ([System.Environment]::MachineName) "" `
-nonewline -foregroundcolor Red
}
$dirname = Split-Path ($pwd.ProviderPath) -Leaf
if ($dirname -eq "") { $dirname = $pwd.ProviderPath }
Write-Host ($dirname) -nonewline -foregroundcolor Green
$global:LASTEXITCODE = $realLASTEXITCODE
return "> "
}
If($host.Name -eq 'ConsoleHost') {
Write-Host -NoNewline "Loading PSReadLine..."
[Console]::CursorLeft = 0
Import-Module PSReadline
Set-PSReadlineOption -MaximumHistoryCount (16 * 1024 * 1024) `
-HistoryNoDuplicates
Set-PSReadlineOption Command -ForegroundColor DarkGreen
Set-PSReadlineOption Comment -ForegroundColor DarkRed
Set-PSReadlineOption Variable -ForegroundColor Magenta
Set-PSReadlineOption Keyword -ForegroundColor Red
Set-PSReadlineOption -EditMode Emacs
Set-PSReadlineKeyHandler Ctrl+D {
$line = $null; $pos = $null;
[PSConsoleUtilities.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$pos)
if ($line -ne "") { return }
[PSConsoleUtilities.PSConsoleReadLine]::Insert("exit")
[PSConsoleUtilities.PSConsoleReadLine]::AcceptLine()
}
Set-PSReadlineKeyHandler Ctrl+RightArrow ShellForwardWord
Set-PSReadlineKeyHandler Ctrl+LeftArrow ShellBackwardWord
Set-PSReadlineKeyHandler Ctrl+Backspace ShellBackwardKillWord
Set-PSReadlineKeyHandler Ctrl+Z Undo
Set-PSReadlineKeyHandler Ctrl+Shift+Z Redo
Set-PSReadlineKeyHandler Ctrl+Shift+V Paste
Set-PSReadlineKeyHandler Ctrl+V Paste
Set-PSReadlineKeyHandler Ctrl+Shift+C Copy
Set-PSReadlineKeyHandler Ctrl+Shift+X Cut
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment