Last active
October 30, 2018 19:14
-
-
Save jessebarocio/59ab48ff99b1e231f25302e9de854596 to your computer and use it in GitHub Desktop.
My PowerShell profile
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
### | |
## 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