-
Notifications
You must be signed in to change notification settings - Fork 2
/
Microsoft.PowerShell_profile.ps1
72 lines (65 loc) · 2.69 KB
/
Microsoft.PowerShell_profile.ps1
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Disable the "make the prompt red during parse error" because it conflicts with oh-my-posh
Set-PSReadLineOption -PromptText ''
function prompt {
# oh-my-posh will override this prompt, however because we're loading it async we want communicate that the
# real prompt is still loading.
"[async init]: PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
}
# Load modules asynchronously and in parallel to reduce shell startup time
@(
{
New-Module -ScriptBlock {
function Set-PoshJobInfo {
$jobs = @(Get-Job)
$running = @($jobs | Where-Object { $_.State -eq "Running"}).Count
if ($running -gt 0)
{
$env:POSH_JOBS_RUNNING = $running
}
else
{
Remove-Item ENV:\POSH_JOBS_RUNNING -ErrorAction SilentlyContinue
}
$finished = ($jobs.Count - $running)
if ($finished -gt 0)
{
$env:POSH_JOBS_FINISHED = $finished
}
else
{
Remove-Item ENV:\POSH_JOBS_FINISHED -ErrorAction SilentlyContinue
}
}
function Set-PoshContexts {
Set-PoshJobInfo
}
# Set-PoshContext is a function called before the prompt is rendered.
New-Alias -Name 'Set-PoshContext' -Value 'Set-PoshContexts' -Scope Global -Force
} | Import-Module -Global
oh-my-posh init pwsh --config (Join-Path (Split-Path $PROFILE) matt.omp.json) | Invoke-Expression
$Env:POSH_GIT_ENABLED = $true
},
{
Import-Module -Name Terminal-Icons -Global
},
{
Import-Module -Name z -Global
},
{
Import-Module -Name (Join-Path (Split-Path $PROFILE) scripts UserScripts.psd1) -Global
},
{
# PowerShell parameter completion shim for the dotnet CLI
Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
dotnet complete --position $cursorPosition "$commandAst" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
},
{
$Env:PYTHONIOENCODING='utf-8'
New-Module -Name thefuck -ScriptBlock { iex "$(thefuck --alias)" } | Import-Module -Global
}
) | Foreach-Object { Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -SupportEvent -Action $_ } | Out-Null