# 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}" # @args you can pass multi arguments for example # ga fileName1 fileName2 function gn{git init} # @args is optional to add argument function add{git add @args} function commit {git commit -m @args } function gac{git add .;git commit -m @args} function gacc{git add .;git commit -m @args ; git push} function gpm{git push origin master} function pull{git pull} function gp{git pull} function gpp{git pull} function gpm{git checkout main ; git pull} function gl{git log} function glo{git log --oneline} function gch{git checkout @args} function gb{git branch @args} function gs{git status} function gss{git status} function gdd{git diff} function gdf{git diff} function gsi{git submodule init} function gsu{git submodule update --recursive --remote} function gr{ni README.md;nano README.md} # choco install nano -y to use nano function gi{ni .gitignore; Add-Content -Path /.gitignore -Value '@args'} # choco install nano -y to use nano # 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 ..\..\.. } function gg { Set-Location $HOME\Syncthing\Git } function ll { Get-ChildItem -Path $pwd -File } # https://www.technewstoday.com/powershell-get-ip-address/ # 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 # for `choco` will not function. # See https://ch0.co/tab-completion for details. $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" if (Test-Path($ChocolateyProfile)) { Import-Module "$ChocolateyProfile" } # https://gist.github.com/yunga/99d04694e2466e017c5502d7c828d4f4 function cs{choco search @args} function parus{choco search @args} function ci{choco install -y @args} 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"} # 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 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)}} }