Update PowerShell Structures

This commit is contained in:
js0ny 2024-08-27 13:16:51 +08:00
parent 7d933a0b16
commit d400f65ae7
8 changed files with 100 additions and 222 deletions

View file

@ -2,100 +2,21 @@
$DOTFILES = "$HOME\.dotfiles"
### PSReadLine ###
### Load Configs ###
Set-PSReadLineOption -EditMode vi # Vi Keybindings
Set-PSReadLineOption -PredictionViewStyle ListView # Prediction View Style
Set-PSReadLineOption -PredictionSource HistoryAndPlugin # Prediction Source
Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Continuation Prompt
Get-ChildItem -Path $DOTFILES\powershell -Filter *.ps1 | ForEach-Object {. $_}
Get-ChildItem -Path $DOTFILES\powershell_private -Filter *.ps1 | ForEach-Object {. $_}
### Keybindings ###
Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord
### Navigator ###
# Relative navigation #
# ${function:~} = { Set-Location -Path ~ } cd is better
${function:...} = { Set-Location -Path ../.. }
${function:....} = { Set-Location -Path ../../.. }
${function:.....} = { Set-Location -Path ../../../.. }
${function:......} = { Set-Location -Path ../../../../.. }
# Absolute navigation #
${function:docs} = { Set-Location -Path ~/Documents }
${function:down} = { Set-Location -Path ~/Downloads }
${function:dt} = { Set-Location -Path ~/Desktop }
${function:mytmp} = { Set-Location -Path ~/Temp }
${function:one} = { Set-Location -Path ~/OneDrive }
${function:doku} = { Set-Location -Path ~/doku && Get-ChildItem }
### Aliases ###
## Aliases ###
# PowerShell Equivalents #
Set-Alias "touch" "New-Item"
Set-Alias "ll" "Get-ChildItem"
Set-Alias "curl" "Invoke-WebRequest"
Set-Alias "man" "Get-Help"
Set-Alias "kill" "Stop-Process"
Set-Alias "open" "Invoke-Item" # Use ii instead of open
# Dev #
${function:shcfg} = { code $PROFILE }
${function:zshcfg} = { nvim ~/.zshrc }
${function:bashcfg} = { nvim ~/.bashrc }
${function:reload} = { Invoke-Expression $PROFILE }
${function:csi} = { dotnet script }
${function:pulldots} = { Set-Location -Path $DOTFILES && git pull }
Set-Alias "pwshcfg" "shcfg"
Set-Alias "cl" "clang"
Set-Alias "cl++" "clang++"
Set-Alias "clang" "clang -std=c99"
Set-Alias "clang++" "clang++ -std=c++2b"
# Python & Conda #
Set-Alias "python3" "python"
Set-Alias "pip3" "pip"
Set-Alias "py" "python"
Set-Alias "pyact" "conda activate"
Set-Alias "pylsenv" "conda env list"
Set-Alias "pydeact" "conda deactivate"
Set-Alias "pymkenv" "conda create --name"
# Editors #
Set-Alias "v" "nvim"
Set-Alias "c" "code"
Set-Alias "gvi" "neovide"
# Miscs #
Set-Alias mcd CreateAndSet-Directory
### Functions ###
function tc { param ( [string] $filename)
New-Item $filename && code $filename
}
function tv { param ( [string] $filename)
New-Item $filename && nvim $filename
}
function cdls { param( [string] $dirname)
Set-Location $dirname && Get-ChildItem
}
### Modules ###
Import-Module CompletionPredictor
# Import-Module syntax-highlighting
### Misc ###
${function:bashcfg} = { nvim ~/.bashrc }