Skip to content

Instantly share code, notes, and snippets.

@dam5s
Created July 26, 2022 16:26
Show Gist options
  • Save dam5s/4d83f894b0ce2c0e46ac3206ad84fad2 to your computer and use it in GitHub Desktop.
Save dam5s/4d83f894b0ce2c0e46ac3206ad84fad2 to your computer and use it in GitHub Desktop.
Powershell Profile
try { $null = gcm pshazz -ea stop; pshazz init } catch { }
function PromptAdmin {
$identity = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent())
$isAdmin = $identity.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if ($isAdmin) {
Write-Host "ADMIN " -NoNewline -ForegroundColor Red
}
}
function PromptFolder {
$currentFolder = $(Get-Item -Path "./")
$isHome = $currentFolder.FullName -eq $HOME
$folderName =
if ($isHome) { "~" }
else { $currentFolder.Name }
$host.ui.RawUI.WindowTitle = $folderName
Write-Host $folderName -NoNewline -ForegroundColor Cyan
}
function PromptGitBranch {
$gitBranch = $(git rev-parse --abbrev-ref HEAD)
if ($gitBranch) {
Write-Host " git:(" -NoNewline -ForegroundColor Blue
Write-Host $gitBranch -NoNewline -ForegroundColor DarkRed
Write-Host ")" -NoNewline -ForegroundColor Blue
$changedFiles = $(git status --porcelain)
if ($changedFiles) {
Write-Host " ✗" -NoNewline -ForegroundColor Yellow
}
}
}
function Prompt {
if ($?) { Write-Host "➜ " -NoNewline -ForegroundColor Green }
else { Write-Host "➜ " -NoNewline -ForegroundColor Red }
PromptAdmin;
PromptFolder;
PromptGitBranch;
return " "
}
Set-PSReadLineOption -EditMode Emacs
Set-PSReadLineOption -Colors @{
Parameter="Green"
Operator="White"
InlinePrediction="DarkMagenta"
}
Set-Alias g git
Set-Alias gw ./gradlew
Set-Alias d dotnet
Set-Alias l ls
Set-Alias which Get-Command
Set-Alias open Start-Process
Set-Alias grep findstr
function jk { npx jake $args }
$env:GIT_SSH = $((Get-Command -Name ssh).Source)
$env:DOTNET_CLI_TELEMETRY_OPTOUT = "1"
$env:JEST_MAX_WORKERS = "8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment