### PowerShell template profile ### Version 1.03 - Tim Sneath ### From https://gist.github.com/timsneath/19867b12eee7fd5af2ba ### ### This file should be stored in $PROFILE.CurrentUserAllHosts ### If $PROFILE.CurrentUserAllHosts doesn't exist, you can make one with the following: ### PS> New-Item $PROFILE.CurrentUserAllHosts -ItemType File -Force ### This will create the file and the containing subdirectory if it doesn't already ### ### As a reminder, to enable unsigned script execution of local scripts on client Windows, ### you need to run this line (or similar) from an elevated PowerShell prompt: ### Set-ExecutionPolicy -ExecutionPolicy RemoteSigned ### This is the default policy on Windows Server 2012 R2 and above for server Windows. For ### more information about execution policies, run Get-Help about_Execution_Policies. # 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 } # ------------------------------------------ function prompt { '>_ ' } function wakeonlan { Send-WakeOnLan -TargetAddress $args[0] } function inet { Set-Location "V:\INTERNET" } function vdq { Set-Location "V:\videoDQ" } Set-Alias npp "C:\Program Files\Notepad++\notepad++.exe" Set-Alias n++ "C:\Program Files\Notepad++\notepad++.exe" Set-Alias yt "C:\tools\bin\yt.ps1" Set-Alias ff "ffmpeg" Set-Alias mpc "mpc-hc64" Set-Alias s "start-process" Set-Alias explo "explorer" # New-Alias -Name art -Value "php artisan" # Set-Alias -Name fresh -Value "php artisan migrate:fresh --seed" function art {php artisan} function fresh {php artisan migrate:fresh --seed} function Play-V { param ( $FilePath ) Start-Process "C:\Program Files\MPC-HC\mpc-hc64.exe" -ArgumentList $FilePath } function ls { ls | Format-Table Name, LastWriteTime -Autosize } function ls10 { ls | Format-Table Name, LastWriteTime, CreationTime, Mode -AutoSize } function Get-Dirs { Get-ChildItem -Directory } function Get-DirsC { Get-ChildItem -Directory | Where-Object { $_.Name -cmatch '^[A-Z]+$' } } function Get-DirsL { Get-ChildItem -Directory | Where-Object { $_.Name -cmatch '^[a-z]+$' } } function touch { param ( [string]$Path ) if (Test-Path $Path) { (Get-Item $Path).LastWriteTime = Get-Date } else { New-Item -Path $Path -ItemType File } } # telegram . "C:\Users\luc\python\pygram\tg.ps1"# ============================================================================= # # Utility functions for zoxide. # # Call zoxide binary, returning the output as UTF-8. function global:__zoxide_bin { $encoding = [Console]::OutputEncoding try { [Console]::OutputEncoding = [System.Text.Utf8Encoding]::new() $result = zoxide @args return $result } finally { [Console]::OutputEncoding = $encoding } } # pwd based on zoxide's format. function global:__zoxide_pwd { $cwd = Get-Location if ($cwd.Provider.Name -eq "FileSystem") { $cwd.ProviderPath } } # cd + custom logic based on the value of _ZO_ECHO. function global:__zoxide_cd($dir, $literal) { $dir = if ($literal) { Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop } else { if ($dir -eq '-' -and ($PSVersionTable.PSVersion -lt 6.1)) { Write-Error "cd - is not supported below PowerShell 6.1. Please upgrade your version of PowerShell." } elseif ($dir -eq '+' -and ($PSVersionTable.PSVersion -lt 6.2)) { Write-Error "cd + is not supported below PowerShell 6.2. Please upgrade your version of PowerShell." } else { Set-Location -Path $dir -Passthru -ErrorAction Stop } } } # ============================================================================= # # Hook configuration for zoxide. # # Hook to add new entries to the database. $global:__zoxide_oldpwd = __zoxide_pwd function global:__zoxide_hook { $result = __zoxide_pwd if ($result -ne $global:__zoxide_oldpwd) { if ($null -ne $result) { zoxide add "--" $result } $global:__zoxide_oldpwd = $result } } # Initialize hook. $global:__zoxide_hooked = (Get-Variable __zoxide_hooked -ErrorAction Ignore -ValueOnly) if ($global:__zoxide_hooked -ne 1) { $global:__zoxide_hooked = 1 $global:__zoxide_prompt_old = $function:prompt function global:prompt { if ($null -ne $__zoxide_prompt_old) { & $__zoxide_prompt_old } $null = __zoxide_hook } } # ============================================================================= # # When using zoxide with --no-cmd, alias these internal functions as desired. # # Jump to a directory using only keywords. function global:__zoxide_z { if ($args.Length -eq 0) { __zoxide_cd ~ $true } elseif ($args.Length -eq 1 -and ($args[0] -eq '-' -or $args[0] -eq '+')) { __zoxide_cd $args[0] $false } elseif ($args.Length -eq 1 -and (Test-Path -PathType Container -LiteralPath $args[0])) { __zoxide_cd $args[0] $true } elseif ($args.Length -eq 1 -and (Test-Path -PathType Container -Path $args[0] )) { __zoxide_cd $args[0] $false } else { $result = __zoxide_pwd if ($null -ne $result) { $result = __zoxide_bin query --exclude $result "--" @args } else { $result = __zoxide_bin query "--" @args } if ($LASTEXITCODE -eq 0) { __zoxide_cd $result $true } } } # Jump to a directory using interactive search. function global:__zoxide_zi { $result = __zoxide_bin query -i "--" @args if ($LASTEXITCODE -eq 0) { __zoxide_cd $result $true } } # ============================================================================= # # Commands for zoxide. Disable these using --no-cmd. # Set-Alias -Name z -Value __zoxide_z -Option AllScope -Scope Global -Force Set-Alias -Name zi -Value __zoxide_zi -Option AllScope -Scope Global -Force # ============================================================================= # # To initialize zoxide, add this to your configuration (find it by running # `echo $profile` in PowerShell): # # Invoke-Expression (& { (zoxide init powershell | Out-String) })