Last active
January 6, 2023 03:10
-
-
Save Avellea/e26b332ed35f70fd961d6f1273d79179 to your computer and use it in GitHub Desktop.
PowerShell prompt
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
# function prompt { | |
# $currentBranch = (&git rev-parse --abbrev-ref HEAD) | |
# # If we are in debug prompt | |
# if (test-path variable:/PSDebugContext) { | |
# Write-Host "[DBG] " -NoNewline -ForegroundColor Gray | |
# } | |
# if ($currentBranch) { | |
# Write-Host "[$currentBranch] " -NoNewline -ForegroundColor Cyan | |
# } | |
# # If terminal is run as administrator, | |
# # make username@hostname red. If not, green. | |
# # #/$ | |
# # Displays `~` as the home directory when in C:\Users\<username> | |
# if([Security.Principal.WindowsIdentity]::GetCurrent().Groups -contains 'S-1-5-32-544') { | |
# Write-Host "$env:UserName@$env:computername".ToLower() -NoNewLine -ForegroundColor red | |
# Write-Host ":" -NoNewLine -ForegroundColor Gray | |
# if($(Get-Location) -like "C:\Users\" + $env:UserName) { | |
# Write-Host "~" -NoNewLine -foregroundColor Blue | |
# } else { | |
# Write-Host "$(Get-Location)" -NoNewLine -ForegroundColor Blue | |
# } | |
# Write-Host "$('#' * ($nestedPromptLevel + 1))" -NoNewline -ForegroundColor White | |
# } else { | |
# Write-Host "$env:UserName@$env:computername".ToLower() -NoNewLine -ForegroundColor Green | |
# Write-Host ":" -NoNewLine -ForegroundColor Gray | |
# if($(Get-Location) -like "C:\Users\" + $env:UserName) { | |
# Write-Host "~" -NoNewLine -foregroundColor Blue | |
# } else { | |
# Write-Host "$(Get-Location)" -NoNewLine -ForegroundColor Blue | |
# } | |
# Write-Host "$('$' * ($nestedPromptLevel + 1))" -NoNewline -ForegroundColor White | |
# } | |
# return " " | |
# } | |
function prompt { | |
if([Security.Principal.WindowsIdentity]::GetCurrent().Groups -contains 'S-1-5-32-544') { | |
Write-Host "$env:computername".ToLower() -NoNewLine -ForegroundColor red | |
if($(Get-Location) -like "C:\Users\" + $env:UserName) { | |
Write-Host " ~" -NoNewLine -foregroundColor Blue | |
} else { | |
Write-Host " $(Get-Location)" -NoNewLine -ForegroundColor Blue | |
} | |
Write-Host "$(' #' * ($nestedPromptLevel + 1))" -NoNewline -ForegroundColor Blue | |
} else { | |
Write-Host "$env:computername".ToLower() -NoNewLine -ForegroundColor Green | |
if($(Get-Location) -like "C:\Users\" + $env:UserName) { | |
Write-Host " ~" -NoNewLine -foregroundColor Blue | |
} else { | |
Write-Host " $(Get-Location)" -NoNewLine -ForegroundColor Blue | |
} | |
Write-Host "$(' >' * ($nestedPromptLevel + 1))" -NoNewline -ForegroundColor Blue | |
} | |
return " " | |
} | |
# Opens the profile.ps1 in VSCode for editing | |
function global:PSProfile-Edit { | |
`code $profile` | |
} | |
# Reloads profile.ps1 | |
function global:PSProfile-Reload { | |
& $profile | |
} | |
# Open current directory in explorer | |
function global:open { | |
PARAM ( | |
[Parameter(Mandatory = $False, Position = 1)] [STRING] $dir | |
) | |
explorer.exe $dir | |
} | |
# Create an empty file | |
function global:touch { | |
PARAM ( | |
[Parameter(Mandatory = $True, Position = 1)] [STRING] $file_name | |
) | |
New-Item ($file_name) | |
} | |
# Edit a file with TUI | |
function global:edit { | |
PARAM ( | |
[Parameter(Mandatory = $True, Position = 1)] [STRING] $file_name | |
) | |
textadept-curses.exe ($file_name) | |
} | |
# Display ANSI console colors. | |
function Get-ConsoleColors { | |
[CmdletBinding()] | |
Param() | |
$List = [enum]::GetValues([System.ConsoleColor]) | |
ForEach ($Color in $List){ | |
Write-Host " $Color" -ForegroundColor $Color -NonewLine | |
Write-Host "" | |
} | |
ForEach ($Color in $List){ | |
Write-Host " " -backgroundColor $Color -noNewLine | |
Write-Host " $Color" | |
} | |
} | |
function ver { | |
$PSVersionTable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment