Added updated profile with misc functions

This commit is contained in:
yuriy 2023-08-19 23:24:35 -04:00
parent f16fe2ae22
commit ce7c678397

View File

@ -1,3 +1,4 @@
# Set the Window Title of Windows Terminal to The filepath of current directory
$host.ui.rawui.windowtitle="$(Get-Item .) - Windows Terminal"
# powershell.exe -NoExit -command "& {Set-Location $env:systemroot}"
@ -25,6 +26,12 @@ function gsi{git submodule init}
function gsu{git submodule update --recursive --remote}
# function gsu{git submodule update --recursive --remote}
# Open up files with specific program
function subl{Start-Process 'C:\Program Files\Sublime Text\sublime_text.exe' @args}
function gimp{Start-Process 'C:\Program Files\GIMP 2\bin\gimp-2.10.exe' @args}
# Useful shortcuts for traversing directories
function cd.. { Set-Location ..\.. }
function cd... { Set-Location ..\..\.. }
@ -35,6 +42,9 @@ function ll { Get-ChildItem -Path $pwd -File }
# get ip address
function ipa { Get-NetIPAddress | Where-Object {$_.AddressState -eq "Preferred" -and $_.ValidLifetime -lt "24:00:00"}}
# Chocolatey
#------------------------------------------------
# Import the Chocolatey Profile that contains the necessary code to enable
# tab-completions to function for `choco`.
# Be aware that if you are missing these lines from your profile, tab completion
@ -45,18 +55,6 @@ if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
# Kill Process
function pkill($name) {
Get-Process $name -ErrorAction SilentlyContinue | Stop-Process
}
# https://www.educative.io/answers/what-is-the-powershell-equivalent-of-touch
function touch{ni @args}
# chocolatey
# https://gist.github.com/yunga/99d04694e2466e017c5502d7c828d4f4
function cs{choco search @args}
function parus{choco search @args}
@ -65,6 +63,19 @@ function paru{choco install -y @args}
function cua{choco upgrade all -y}
# Misc
#------------------------------------------------
# Kill Process
function pkill($name) {
Get-Process $name -ErrorAction SilentlyContinue | Stop-Process
}
# https://www.educative.io/answers/what-is-the-powershell-equivalent-of-touch
function touch{ni @args}
# reload profile
# https://stackoverflow.com/questions/567650/how-to-reload-user-profile-from-script-file-in-powershell
function rl{. $profile ; Write-Host "Reloaded"}
@ -73,3 +84,44 @@ function rl{. $profile ; Write-Host "Reloaded"}
# yt-dlp
function ytv{yt-dlp -f bestvideo*+bestaudio/best --embed-thumbnail --add-metadata --no-mtime --no-playlist -o "%(title)s.%(ext)s" @args}
function yta{yt-dlp -f bestaudio --extract-audio --embed-thumbnail --add-metadata --no-mtime --no-playlist -o "%(title)s.%(ext)s" @args}
# Compute file hashes
function md5 { Get-FileHash -Algorithm MD5 $args }
function sha1 { Get-FileHash -Algorithm SHA1 $args }
function sha256 { Get-FileHash -Algorithm SHA256 $args }
# 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 "$psHome\powershell.exe" -Verb runAs -ArgumentList $argList
}
else
{
Start-Process "$psHome\powershell.exe" -Verb runAs
}
}
# Set UNIX-like aliases for the admin command, so sudo <command> will run the command with elevated rights.
Set-Alias -Name sudo -Value admin
# Edit the Powershell Profile
function editps1
{
Start-Process 'C:\Program Files\Sublime Text\sublime_text.exe' ${profile}
}
# Get Uptime
function uptime {
Get-WmiObject win32_operatingsystem | Select-Object csname, @{LABEL='LastBootUpTime';
EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
}