Skip to content

Instantly share code, notes, and snippets.

@RoadToDream
Last active June 8, 2024 18:45
Show Gist options
  • Select an option

  • Save RoadToDream/d799fb837596210174829b48c4c9a71f to your computer and use it in GitHub Desktop.

Select an option

Save RoadToDream/d799fb837596210174829b48c4c9a71f to your computer and use it in GitHub Desktop.
PowerShell profile
Set-PSReadLineOption -EditMode Emacs
Set-PSReadLineKeyHandler -Chord Ctrl+LeftArrow BackwardWord
Set-PSReadLineKeyHandler -Chord Ctrl+RightArrow ForwardWord
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
# This will not load oh-my-posh and posh-git module on start up, but will load after the first command
# Reason for that is because oh-my-posh or posh-git takes a lot of time to load, especially for the
# first time after the boot(3-5 seconds). With that we can get PowerShell ready to use instantly.
$global:globalPromptInvokedCount = 0
Function prompt() {
if ($global:globalPromptInvokedCount -eq 0) {
$global:globalPromptInvokedCount++
} elseif ($global:globalPromptInvokedCount -eq 1) {
oh-my-posh init pwsh --config "C:\Users\jduan\AppData\Local\Programs\oh-my-posh\themes\zash_custom.omp.json" | Invoke-Expression
Import-Module posh-git
$global:globalPromptInvokedCount++
prompt
}
}
@RoadToDream
Copy link
Copy Markdown
Author

Hope this will help anyone who is also suffered from the loading time.
oh-my-posh takes a lot of time to load. #1624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment