install.fairie/home/dot_config/powershell/profile.ps1

55 lines
2 KiB
PowerShell
Raw Normal View History

2023-06-18 20:30:41 -07:00
# [PSFzf](https://github.com/kelleyma49/PSFzf)
# [DockerCompletion](https://github.com/matt9ucci/DockerCompletion)
2023-06-09 17:49:42 -07:00
### Env
$env:EDITOR = 'code --wait'
$env:GIT_SSH = "C:\Windows\system32\OpenSSH\ssh.exe"
2023-06-09 17:49:42 -07:00
### Set PowerShell to UTF-8
2023-06-18 20:30:41 -07:00
[Console]::InputEncoding = [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
2023-06-09 17:49:42 -07:00
### PSReadLine
2023-06-09 17:54:02 -07:00
Set-PSReadLineOption -EditMode Vi
Set-PSReadLineOption -BellStyle None
Set-PSReadLineKeyHandler -Chord 'Ctrl+d' -Function DeleteChar
Set-PSReadLineOption -PredictionSource History
2023-06-18 20:30:41 -07:00
### Import PowerShell modules
$modules = @("Carbon", "ImportExcel", "Microsoft.PowerShell.ConsoleGuiTools", "Microsoft.PowerShell.PSResourceGet", "PSFzf", "PSWindowsUpdate", "PackageManagement", "PendingReboot", "posh-git", "Terminal-Icons")
foreach ($module in $modules) {
if (-not (Get-Module -ListAvailable -Name $module)) {
Install-Module -Name $module -Scope CurrentUser -Force -Repository PSGallery -AllowPrerelease
}
Import-Module $module -Force
}
2023-07-08 23:46:28 -07:00
### Homebrew
Add-Content -Path $PROFILE.CurrentUserAllHosts -Value '$(/usr/local/bin/brew shellenv) | Invoke-Expression'
2023-06-18 20:30:41 -07:00
### posh-git settings
oh-my-posh init pwsh --config "$env:HOME/.config/oh-my-posh/Betelgeuse.omp.json" | Invoke-Expression
### PSFzf settings
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
$commandOverride = [ScriptBlock]::Create("param(\$Location) Set-Location \$Location")
Set-PsFzfOption -AltCCommand $commandOverride
Set-PsFzfOption -TabExpansion
$env:_PSFZF_FZF_DEFAULT_OPTS = "--ansi --preview 'bat --color=always {}'"
Set-PSFzfOption -EnableAlias
### zoxide
2023-06-18 20:30:41 -07:00
Invoke-Expression '& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { "prompt" } else { "pwd" }
(zoxide init --hook $hook powershell | Out-String)
2023-06-18 20:30:41 -07:00
}'
### Aliases
2023-06-18 20:30:41 -07:00
Set-Alias grep Select-String
### Utilities
function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
2023-06-18 20:30:41 -07:00
Select-Object -ExpandProperty Source -ErrorAction SilentlyContinue
}