Skip to content

Instantly share code, notes, and snippets.

@HymanZHAN
Last active August 16, 2022 13:36
Show Gist options
  • Save HymanZHAN/5cbfa9a3f10ebd8899886376a206877a to your computer and use it in GitHub Desktop.
Save HymanZHAN/5cbfa9a3f10ebd8899886376a206877a to your computer and use it in GitHub Desktop.
Personal PS1 profile
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
# Env
$ENV:STARSHIP_CONFIG = "$HOME\.starship\starship.toml"
# Installed Module
Import-Module posh-git
Import-Module npm-completion
# Aliases
Set-Alias -Name ll -Value Get-ChildItem
Set-Alias -Name quit -Value exit
Set-Alias -Name touch -Value New-Item
Set-Alias -Name vim -Value nvim
# Built-In PSReadLine Options
Set-PSReadLineOption -HistoryNoDuplicates
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -HistorySaveStyle SaveIncrementally
Set-PSReadLineOption -MaximumHistoryCount 4000
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# Personal Functions
function mooc {
Set-Location -Path "$env:USERPROFILE\Development\MOOC"
}
function wk {
Set-Location -Path "$env:USERPROFILE\Development\Work"
}
function proj {
Set-Location -Path "$env:USERPROFILE\Development\Projects"
}
function pk {
Set-Location -Path "$env:USERPROFILE\Development\Packages"
}
function which {
param (
$command
)
Get-Command $command | Format-Table Name, Path
}
function dcud {
Invoke-Command -ScriptBlock { docker-compose up -d }
}
function dex {
param (
$service, $command
)
Invoke-Command -ScriptBlock { docker-compose exec $service $command }
}
function dcs {
Invoke-Command -ScriptBlock { docker-compose stop }
}
function dsa {
Invoke-Command -ScriptBlock { docker stop $(docker ps -q -a) }
}
function proxyon {
Invoke-Command -ScriptBlock { $Env:http_proxy = "http://127.0.0.1:7890"; $Env:https_proxy = "http://127.0.0.1:7890" }
}
# auto completion for dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
dotnet complete --position $cursorPosition "$wordToComplete" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Import-Module "$HOME\.pwsh\Deno.psm1"
Import-Module "$HOME\.pwsh\Fnm.psm1"
Import-Module "$HOME\.pwsh\RustUp.psm1"
fnm env --use-on-cd | Out-String | Invoke-Expression
Invoke-Expression (&starship init powershell)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment