Skip to content

Instantly share code, notes, and snippets.

@t-makaro
Created October 21, 2018 22:42
Show Gist options
  • Save t-makaro/3a222a95d61938f75684b87a2f4e24b6 to your computer and use it in GitHub Desktop.
Save t-makaro/3a222a95d61938f75684b87a2f4e24b6 to your computer and use it in GitHub Desktop.
My powershell profile
# *************************************************************************
# Script Name: profile.ps1
# Version: 1.2
# Author: Tyler Makaro
# Date: August 28, 2018
#
# Description: Custom profile for windows powershell.
# *************************************************************************
# Create a custom prompt
function prompt {
$origLastExitCode = $LASTEXITCODE
Write-Host 'PS ' -ForegroundColor Darkcyan -nonewline
Write-VcsStatus
$maxPathLength = 80
$curPath = $ExecutionContext.SessionState.Path.CurrentLocation.Path
if ($curPath.Length -gt $maxPathLength) {
$curPath = '...' + $curPath.SubString($curPath.Length - $maxPathLength + 3)
}
Write-Host $curPath -ForegroundColor White
$LASTEXITCODE = $origLastExitCode
"$('>' * ($nestedPromptLevel + 1)) "
}
function which($name) {
Get-Command $name | Select-Object -ExpandProperty Source
}
# Stop saving command history
Set-PSReadlineOption -HistorySaveStyle SaveNothing
# Enable git support
Import-Module posh-git
$global:GitPromptSettings.BeforeText = '['
$global:GitPromptSettings.AfterText = '] '
# Color highlighting
Import-Module Get-ChildItemColor
Set-Alias dir Get-ChildItemColor -option AllScope -Force
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment