|
#Set UTF-8 |
|
#$PSDefaultParameterValues["Out-File:Encoding"] = "utf8" |
|
$PSDefaultParameterValues = @{ '*:Encoding' = 'utf8' } |
|
|
|
if ($host.Name -eq 'ConsoleHost') |
|
{ |
|
Import-Module oh-my-posh |
|
# |
|
#Themes link: https://ohmyposh.dev/docs/themes |
|
# |
|
#Set-PoshPrompt -Theme jandedobbeleer |
|
#Set-PoshPrompt -Theme marcduiker |
|
Set-PoshPrompt -Theme aliens |
|
|
|
Import-Module -Name Terminal-Icons |
|
Import-Module PSReadLine |
|
Set-PSReadLineOption -PredictionSource History |
|
Set-PSReadLineOption -PredictionViewStyle ListView |
|
Set-PSReadLineOption -EditMode Windows |
|
|
|
# bash-style completion |
|
Set-PSReadlineKeyHandler -Key Tab -Function Complete |
|
|
|
Clear-Host |
|
} |
|
|
|
function aliasLr {Get-ChildItem -Recurse} |
|
|
|
New-Alias -Name "ll" -Value "Get-ChildItem" -Description "Old Bash habbits never die" |
|
New-Alias -Name "lr" -Value aliasLr |
|
New-Alias -Name "nano" -Value "C:\Program Files\Notepad3\Notepad3.exe" |
|
|
|
|
|
|
|
|
|
# Useful shortcuts for traversing directories |
|
function cd... { cd ..\.. } |
|
function cd.... { cd ..\..\.. } |
|
|
|
# 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 } |
|
|
|
# Quick shortcut to start notepad |
|
function n { notepad $args } |
|
|
|
# Drive shortcuts |
|
function HKLM: { Set-Location HKLM: } |
|
function HKCU: { Set-Location HKCU: } |
|
function Env: { Set-Location Env: } |
|
|
|
|
|
# Does the the rough equivalent of dir /s /b. For example, dirs *.png is dir /s /b *.png |
|
function dirs |
|
{ |
|
if ($args.Count -gt 0) |
|
{ |
|
Get-ChildItem -Recurse -Include "$args" | Foreach-Object FullName |
|
} |
|
else |
|
{ |
|
Get-ChildItem -Recurse | Foreach-Object FullName |
|
} |
|
} |
|
|
|
# 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) |
|
{ |
|
Stop-Process -Id $Processes[0].id |
|
} |
|
else |
|
{ |
|
Start-Process -Verb RunAs wt |
|
} |
|
} |
|
|
|
|
|
# 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 |
|
|
|
|
|
# Make it easy to edit this profile once it's installed |
|
function Edit-Profile |
|
{ |
|
if ($host.Name -match "ise") |
|
{ |
|
$psISE.CurrentPowerShellTab.Files.Add($profile.CurrentUserAllHosts) |
|
} |
|
else |
|
{ |
|
notepad $profile |
|
} |
|
} |
|
|