Skip to content

Instantly share code, notes, and snippets.

@jessebarocio
Last active October 30, 2018 19:14
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 jessebarocio/59ab48ff99b1e231f25302e9de854596 to your computer and use it in GitHub Desktop.
Save jessebarocio/59ab48ff99b1e231f25302e9de854596 to your computer and use it in GitHub Desktop.
My PowerShell profile
###
## NOTE: This assumes the folliwng:
## - PS 5.x
## - posh-git (https://github.com/dahlbyk/posh-git) 1.x is installed
###
###
## Helper Functions
###
# Determines if the user is an admin
function Test-IsAdmin {
return ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
# .gitignore generator
Function gig {
param(
[Parameter(Mandatory=$true)]
[string[]]$list
)
$params = ($list | ForEach-Object { [uri]::EscapeDataString($_) }) -join ","
Invoke-WebRequest -Uri "https://www.gitignore.io/api/$params" | select -ExpandProperty content | Out-File -FilePath $(Join-Path -path $pwd -ChildPath ".gitignore") -Encoding ascii
}
###
## Custom Prompt
###
Import-Module posh-git
function Set-PromptPrefix {
$prefix = "$([char]0x00A7) "
if(Test-IsAdmin) {
$prefix = "$prefix[ADMIN] "
}
$GitPromptSettings.DefaultPromptPrefix.Text = $prefix
$GitPromptSettings.DefaultPromptPrefix.ForegroundColor = [ConsoleColor]::Yellow
}
Set-PromptPrefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment