Created
August 26, 2020 19:55
-
-
Save TDarkShadow/45557c88e507e51f6d14645523579b8e to your computer and use it in GitHub Desktop.
A temporary backup of my personal PS profile (without secrets)
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
### PowerShell template profile | |
### Based from https://gist.github.com/timsneath/19867b12eee7fd5af2ba | |
### And https://hodgkins.io/ultimate-powershell-prompt-and-git-setup | |
# foreach ($arg in [Environment]::GetCommandLineArgs()) { | |
# if (!($arg -like '-NoLogo')) { | |
# Start-Process PowerShell -Verb "-NoLogo" | |
# } | |
# } | |
# Window title shows the version of the powershell in use. | |
$Host.UI.RawUI.WindowTitle = "PowerShell {0}" -f $PSVersionTable.PSVersion.ToString() | |
# Find out if the current user identity is elevated (has admin rights) | |
function Test-Administrator { | |
$user = [Security.Principal.WindowsIdentity]::GetCurrent(); | |
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) | |
} | |
# If running with admin priviliges, adds a [ADMIN] suffix after the window title. | |
if (Test-Administrator) | |
{ | |
$Host.UI.RawUI.WindowTitle += " [ADMIN]" | |
} | |
# Simple function to start a new elevated process. | |
# If arguments are supplied then a single command is started with admin rights. | |
# If not then a new admin instance of PowerShell is started. | |
function admin | |
{ | |
if ($args.Count -gt 0) | |
{ | |
$argList = "& '" + $args + "'" | |
Start-Process PowerShell -Verb runAs -ArgumentList $argList | |
} | |
else | |
{ | |
Start-Process PowerShell -Verb runAs | |
} | |
exit | |
} | |
# Set UNIX-like aliases for the admin command, | |
# so sudo <command> will run the command with elevated rights. | |
Set-Alias -Name su -Value admin | |
Set-Alias -Name sudo -Value admin | |
# Set long UNIX alias for Get-Childitem command. | |
Set-Alias -Name list -Value Get-Childitem | |
# Compute file hashes - useful for checking successful downloads | |
function md5 { Get-FileHash -Algorithm MD5 $args } | |
function sha1 { Get-FileHash -Algorithm SHA1 $args } | |
function sha256 { Get-FileHash -Algorithm SHA256 $args } | |
# Creating / Editing this Profile file | |
function profile { | |
if (!(Test-Path -Path $PROFILE)) { | |
New-Item -Path $PROFILE -ItemType File | |
} | |
ise $PROFILE | |
} | |
# Chocolatey profile | |
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" | |
if (Test-Path($ChocolateyProfile)) { | |
Import-Module "$ChocolateyProfile" | |
} | |
function prompt { | |
$realLASTEXITCODE = $LASTEXITCODE | |
Write-Host | |
Write-Host -ForegroundColor Green (Get-Location) | |
Write-Host -nonewline -ForegroundColor Gray ">" | |
" " | |
} | |
# Make the Powershell version into a variable for easier logging. | |
$PowershellVersion = [string]$PSVersionTable.PSVersion.Major + "." + [string]$PSVersionTable.PSVersion.Minor | |
Set-Location C:\ | |
Clear-Host | |
Write-Host "You are logged in as $env:username on $env:computername" | |
Write-Host "Today:" (Get-Date) | |
Write-Host "PowerShell $PowershellVersion is awaiting your commands." | |
# Import-Module posh-git | |
# Import-Module oh-my-posh | |
# Set-Theme Paradox | |
Import-Module PoShFuck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment