Created
December 19, 2018 20:11
-
-
Save nickknissen/bfb0dfafce3c017c5f00f93aa36cf436 to your computer and use it in GitHub Desktop.
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
Import-Module Get-ChildItemColor | |
Import-Module PSReadLine | |
Set-Alias l Get-ChildItemColor -option AllScope | |
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope | |
Set-Alias dir Get-ChildItemColor -option AllScope -Force | |
Set-Alias dc docker-compose | |
function DockerCompose-Exec() { | |
docker-compose exec $args | |
} | |
Set-Alias dce DockerCompose-Exec | |
Set-PSReadLineOption -HistoryNoDuplicates | |
Set-PSReadLineOption -HistorySearchCursorMovesToEnd | |
Set-PSReadLineOption -HistorySaveStyle SaveIncrementally | |
Set-PSReadLineOption -MaximumHistoryCount 512 | |
# history substring search | |
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward | |
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward | |
# Tab completion | |
Set-PSReadlineKeyHandler -Chord 'Shift+Tab' -Function Complete | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
# http://serverfault.com/questions/95431 | |
function Test-Administrator { | |
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | |
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
function prompt { | |
# https://github.com/dahlbyk/posh-git/wiki/Customizing-Your-PowerShell-Prompt | |
$origLastExitCode = $LastExitCode | |
Write-VcsStatus | |
if (Test-Administrator) { # if elevated | |
Write-Host "(Elevated) " -NoNewline -ForegroundColor White | |
} | |
Write-Host "$env:USERNAME@" -NoNewline -ForegroundColor DarkYellow | |
Write-Host "$env:COMPUTERNAME" -NoNewline -ForegroundColor Magenta | |
Write-Host " : " -NoNewline -ForegroundColor DarkGray | |
$curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path | |
if ($curPath.ToLower().StartsWith($Home.ToLower())) | |
{ | |
$curPath = "~" + $curPath.SubString($Home.Length) | |
} | |
Write-Host $curPath -NoNewline -ForegroundColor Blue | |
Write-Host " : " -NoNewline -ForegroundColor DarkGray | |
Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor DarkMagenta | |
Write-Host " : " -NoNewline -ForegroundColor DarkGray | |
$LastExitCode = $origLastExitCode | |
"`n$('>' * ($nestedPromptLevel + 1)) " | |
} | |
# Import-Module posh-git | |
#$global:GitPromptSettings.BeforeText = '[' | |
#$global:GitPromptSettings.AfterText = '] ' | |
function cddash { | |
if ($args[0] -eq '-') { | |
$pwd = $OLDPWD; | |
} else { | |
$pwd = $args[0]; | |
} | |
$tmp = pwd; | |
if ($pwd) { | |
Set-Location $pwd; | |
} | |
Set-Variable -Name OLDPWD -Value $tmp -Scope global; | |
} | |
Set-Alias -Name cd -value cddash -Option AllScope | |
# Chocolatey profile | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment