# $OMP_THEME="agnoster" # Autocomplete # Install-Module PSReadLine -Force Set-PSReadLineOption -PredictionSource History Set-PSReadLineOption -PredictionViewStyle ListView Set-PSReadLineOption -HistoryNoDuplicates Set-PSReadLineKeyHandler -Key Tab -Function Complete # Vi mode Set-PSReadLineOption -EditMode Vi $env:SHELL_VI_MODE = "I" Set-PSReadlineOption -ViModeIndicator Script -ViModeChangeHandler { param($mode) if ($mode -eq "Command") { $env:SHELL_VI_MODE = "N" } else { $env:SHELL_VI_MODE = "I" } [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt() } # Set-PSReadLineKeyHandler -Key 'alt+k' -Function HistorySearchBackward # Set-PSReadLineKeyHandler -Key 'alt+j' -Function HistorySearchForward Set-PSReadLineKeyHandler -Key 'ctrl+p' -Function HistorySearchBackward Set-PSReadLineKeyHandler -Key 'ctrl+n' -Function HistorySearchForward # useful bindings Set-PSReadLineKeyHandler 'ctrl+o' -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::Insert('lfcd') [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() } Set-PSReadLineKeyHandler 'ctrl+f' -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::Insert('fzf | Split-Path | cd') [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() } Set-PSReadLineKeyHandler 'ctrl+e' -ScriptBlock { [Microsoft.PowerShell.PSConsoleReadLine]::Insert('nvim "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json"') [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() } function lfcd { $tmp = New-TemporaryFile lf -last-dir-path="$tmp" @args if (Test-Path -Path "$tmp" -PathType Leaf) { $dir = $(cat "$tmp") Remove-Item -Path "$tmp" -Force if (Test-Path -Path "$dir") { if ("$dir" -ne "$(pwd)") { cd "$dir" } } } } if ($OMP_THEME -eq $null) { $OMP_THEME_PATH="$env:USERPROFILE\.config\oh-my-posh\config.json" } else { $OMP_THEME_PATH="$env:POSH_THEMES_PATH$OMP_THEME.omp.json" } oh-my-posh init pwsh --config "$OMP_THEME_PATH" | Invoke-Expression ################################################# New-Alias which get-command function bash {& "$env:ProgramFiles\Git\bin\sh.exe" --login} function activate {& ".\.venv\Scripts\activate"} # for using with uv venv (python) function lnj { cmd /c mklink /j $args } # link target (/d -> simbólico mais livre, /h -> físico) function file-monitoring-size { $LastLength = 1 $NewLength = (Get-Item $args).Length Write-Output ("{0:N2} GB" -f ($NewLength / 1GB)) while ($NewLength -ne $LastLength) { $LastLength = $NewLength Start-Sleep -Seconds 5 $NewLength = (Get-Item $args).Length Write-Output ("{0:N2} GB" -f ($NewLength / 1GB)) } } # Amazon Q function q { wsl q $args } function qlogin { q login } function qchat { q chat "$args" --no-interactive }