win-scripts/profile.ps1
2023-01-20 14:21:50 +01:00

80 lines
2.2 KiB
PowerShell

using namespace System.Management.Automation
Import-Module PSReadLine
# Setting up PATH
$env:Path = "$HOME/Bin/system/;" + "$env:Path"
$env:Path = "$HOME/Bin/custom/;" + "$env:Path"
$versionMinimum = [Version]'7.1.999'
if (($Host.Name -eq 'ConsoleHost') -and ($PSVersionTable.PSVersion -ge $versionMinimum))
{
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
}
else
{
Set-PSReadLineOption -PredictionSource History
}
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadlineOption -Color @{
"Command" = [ConsoleColor]::Green
"Parameter" = [ConsoleColor]::Gray
"Operator" = [ConsoleColor]::Magenta
"Variable" = [ConsoleColor]::White
"String" = [ConsoleColor]::Yellow
"Number" = [ConsoleColor]::Blue
"Type" = [ConsoleColor]::Cyan
"Comment" = [ConsoleColor]::DarkCyan
}
$OnViModeChange = [scriptblock]{
if ($args[0] -eq 'Command') {
# Set the cursor to a blinking block.
Write-Host -NoNewLine "`e[1 q"
}
else {
# Set the cursor to a blinking line.
Write-Host -NoNewLine "`e[5 q"
}
}
Set-PsReadLineOption -EditMode Vi # -ViModeIndicator Cursor
Set-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $OnViModeChange
# Get fzf on drugs
Import-Module PSFzf
# replace 'Ctrl+t' and 'Ctrl+r' with your preferred bindings:
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
Set-PsFzfOption -EnableAliasFuzzyScoop -EnableAliasFuzzyKillProcess
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
function dl {
Set-Location ~\Downloads
aria2c -j 16 -s 16 -x 16 -k 5M --file-allocation=none $args[0]
}
function ls_pretty {
lsd -1 $args
}
function profile {
nvim C:\Users\Crony\Documents\Repos\win-scipts\profile.ps1
}
New-Alias vi nvim-qt.exe
# Remove-Alias ls
# New-Alias ls ls_pretty
Invoke-Expression (&starship init powershell)