Skip to content

Instantly share code, notes, and snippets.

@emmet-m
Created February 8, 2019 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emmet-m/c75210f4d83337e312c63e8a235974da to your computer and use it in GitHub Desktop.
Save emmet-m/c75210f4d83337e312c63e8a235974da to your computer and use it in GitHub Desktop.
My current PowerShell profile!
#PsGet. May require manually installing each of these...
Import-Module PsGet
Import-Module PowerLS
Import-Module FindString
#Unix like ls:
Remove-Item alias:ls
Set-Alias -Name ls -Value PowerLS -Option AllScope
Set-Alias -Name lls -Value PowerLS -Option AllScope
Set-Alias -Name grep -Value FindString -Option AllScope
# Turn off that silly beep
Set-PSReadlineOption -BellStyle None
# Change prompt
function prompt
{
Write-Host ("(") -nonewline -foregroundcolor Cyan
Write-Host ($(Get-Branch)) -nonewline -ForegroundColor DarkYellow
Write-Host (")") -nonewline -foregroundcolor Cyan
Write-Host ("[") -nonewline -foregroundcolor Cyan
Write-Host ($(Get-Location)) -nonewline -foregroundcolor Yellow
Write-Host ("]") -nonewline -foregroundcolor Cyan
Write-Host ("`r`n|") -nonewline -foregroundcolor Yellow
Write-Host ("λ") -nonewline -foregroundcolor DarkRed
Write-Host ("> ") -nonewline -foregroundcolor Yellow
return " "
}
# Aliases
$PSRC = "~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"
function vscode($File) {
code -a $File
}
Set-Alias -Name vim -Value vscode # I'm too used to using vim for everything...
# Returns the current git branch, or nothing if not inside a git repo
function Get-Branch() {
return $(git rev-parse --abbrev-ref HEAD)
}
#Shows all the files that have changed since the start of the current branch
function Show-Changed-Files() {
$Branch = Get-Branch
git diff --name-only $Branch $(git merge-base $Branch master)
}
# Unix which replacement
Set-Alias which Get-Command
# Shortcut for windows diff
function Show-Difference($File1, $File2) {
Compare-Object (Get-Content $File1) (Get-Content $File2)
}
Remove-Item -Force alias:diff
Set-Alias -Name diff -Value Show-Difference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment