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

56 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-08-06 22:19:59 -07:00
### Carapace
Set-PSReadLineOption -Colors @{ "Selection" = "`e[7m" }
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
carapace _carapace | Out-String | Invoke-Expression
2023-07-08 23:46:28 -07:00
### Homebrew
# TODO - Add for case where value is /opt/homebrew/bin/brew shellenv
2023-07-08 23:46:28 -07:00
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'
Set-PsFzfOption -TabExpansion
$env:_PSFZF_FZF_DEFAULT_OPTS = "--ansi --preview 'bat --color=always {}'"
2023-07-12 20:22:30 -07:00
Set-PSFzfOption -EnableAliasFuzzySetEverything
### zoxide
2023-07-12 20:22:30 -07:00
Invoke-Expression (& { (zoxide init powershell | Out-String) })
### 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
}