diff --git a/dotfiles/.config/powershell/user_profile.ps1 b/dotfiles/.config/powershell/user_profile.ps1 index 09333da3..bb241d11 100644 --- a/dotfiles/.config/powershell/user_profile.ps1 +++ b/dotfiles/.config/powershell/user_profile.ps1 @@ -1,14 +1,21 @@ # set PowerShell to UTF-8 [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding +Install-Module posh-git -Scope CurrentUser +Install-Module oh-my-posh -Scope CurrentUser +Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck +Set-Prompt + Import-Module posh-git +Import-Module oh-my-posh $omp_config = Join-Path $PSScriptRoot ".\takuya.omp.json" oh-my-posh --init --shell pwsh --config $omp_config | Invoke-Expression +Set-Theme Paradox Import-Module -Name Terminal-Icons # PSReadLine -Set-PSReadLineOption -EditMode Emacs +Set-PSReadLineOption -EditMode Vim Set-PSReadLineOption -BellStyle None Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar Set-PSReadLineOption -PredictionSource History @@ -17,18 +24,19 @@ Set-PSReadLineOption -PredictionSource History Import-Module PSFzf Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+f' -PSReadlineChordReverseHistory 'Ctrl+r' +### zoxide +Invoke-Expression (& { + $hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' } + (zoxide init --hook $hook powershell | Out-String) +}) + # Env $env:GIT_SSH = "C:\Windows\system32\OpenSSH\ssh.exe" -# Alias -Set-Alias -Name vim -Value nvim -Set-Alias ll ls -Set-Alias g git +### Aliases Set-Alias grep findstr -Set-Alias tig 'C:\Program Files\Git\usr\bin\tig.exe' -Set-Alias less 'C:\Program Files\Git\usr\bin\less.exe' -# Utilities +### Utilities function which ($command) { Get-Command -Name $command -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue