-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.PowerShell_profile.ps1.tmpl
54 lines (43 loc) · 1.92 KB
/
Microsoft.PowerShell_profile.ps1.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{{- if eq .chezmoi.os "windows" -}}
# https://ohmyposh.dev/docs/faq#my-prompt-is-broken-after-upgrading-to-powershell-74
[Console]::OutputEncoding = [Text.Encoding]::UTF8
# default command to load oh-my-posh including default theme
# oh-my-posh init pwsh | Invoke-Expression
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\night-owl.omp.json | Invoke-Expression
# load powershell modules
$modules = "posh-git", "Terminal-Icons", "PsReadLine"
foreach ($module in $modules) {
if (-not (Get-Module -ListAvailable -Name $module)) {
Install-Module -Name $module -Scope CurrentUser -Force -SkipPublisherCheck
}
Import-Module -Name $module
}
# Azure ClI Tab Completion
Register-ArgumentCompleter -Native -CommandName az -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$completion_file = New-TemporaryFile
$env:ARGCOMPLETE_USE_TEMPFILES = 1
$env:_ARGCOMPLETE_STDOUT_FILENAME = $completion_file
$env:COMP_LINE = $wordToComplete
$env:COMP_POINT = $cursorPosition
$env:_ARGCOMPLETE = 1
$env:_ARGCOMPLETE_SUPPRESS_SPACE = 0
$env:_ARGCOMPLETE_IFS = "`n"
$env:_ARGCOMPLETE_SHELL = 'powershell'
az 2>&1 | Out-Null
Get-Content $completion_file | Sort-Object | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)
}
Remove-Item $completion_file, Env:\_ARGCOMPLETE_STDOUT_FILENAME, Env:\ARGCOMPLETE_USE_TEMPFILES, Env:\COMP_LINE, Env:\COMP_POINT, Env:\_ARGCOMPLETE, Env:\_ARGCOMPLETE_SUPPRESS_SPACE, Env:\_ARGCOMPLETE_IFS, Env:\_ARGCOMPLETE_SHELL
}
# Chezmoi Wrapper
. "$env:USERPROFILE/Scripts/PowerShell/chezmoi.ps1"
# PSReadLine config
. "$env:USERPROFILE/Scripts/PowerShell/psreadline.ps1"
# Githelpers
. "$env:USERPROFILE/Scripts/PowerShell/githelpers.ps1"
# Linux like commands for Windows
. "$env:USERPROFILE/Scripts/PowerShell/linuxlike.ps1"
# Utils
. "$env:USERPROFILE/Scripts/PowerShell/utils.ps1"
{{- end }}