-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
100 lines (81 loc) · 3.52 KB
/
Microsoft.PowerShell_profile.ps1
File metadata and controls
100 lines (81 loc) · 3.52 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
# Import Modules and External Profiles
# Ensure Terminal-Icons module is installed before importing
if (-not (Get-Module -ListAvailable -Name Terminal-Icons)) {
Install-Module -Name Terminal-Icons -Scope CurrentUser -Force -SkipPublisherCheck
}
Import-Module -Name Terminal-Icons
if (-not (Get-Module -ListAvailable -Name Catppuccin)) {
Install-Module -Name Catppuccin -Scope CurrentUser -Force -SkipPublisherCheck
}
Import-Module -Name Catppuccin
# Set a flavor for easy access
$Flavor = $Catppuccin['Mocha']
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
$profileDir = $PSScriptRoot;
$SWPDM_Scripts = "$profileDir\SolidworksPDM.ps1"
$PSReadLine_Scripts = "$profileDir\PSReadLineProfile.ps1"
. $SWPDM_Scripts
. $PSReadLine_Scripts
$Colors = @{
# Largely based on the Code Editor style guide
# Emphasis, ListPrediction and ListPredictionSelected are inspired by the Catppuccin fzf theme
# Powershell colours
ContinuationPrompt = $Flavor.Teal.Foreground()
Emphasis = $Flavor.Red.Foreground()
Selection = $Flavor.Surface0.Background()
# PSReadLine prediction colours
InlinePrediction = $Flavor.Overlay0.Foreground()
ListPrediction = $Flavor.Mauve.Foreground()
ListPredictionSelected = $Flavor.Surface0.Background()
# Syntax highlighting
Command = $Flavor.Blue.Foreground()
Comment = $Flavor.Overlay0.Foreground()
Default = $Flavor.Text.Foreground()
Error = $Flavor.Red.Foreground()
Keyword = $Flavor.Mauve.Foreground()
Member = $Flavor.Rosewater.Foreground()
Number = $Flavor.Peach.Foreground()
Operator = $Flavor.Sky.Foreground()
Parameter = $Flavor.Pink.Foreground()
String = $Flavor.Green.Foreground()
Type = $Flavor.Yellow.Foreground()
Variable = $Flavor.Lavender.Foreground()
}
# Set the colours
Set-PSReadLineOption -Colors $Colors
$env:path += ";$ProfileDir\Scripts"
function Set-WindowTitle {
$host.UI.RawUI.WindowTitle = [string]::Join(" ", $args)
}
function prompt {
Write-Host $ExecutionContext.SessionState.Path.CurrentLocation -ForegroundColor Green
Write-Host "$('>:' * ($nestedPromptLevel + 1))" -NoNewLine
return " "
}
function Show-Colors( ) {
$colors = [Enum]::GetValues( [ConsoleColor] )
$max = ($colors | ForEach-Object { "$_ ".Length } | Measure-Object -Maximum).Maximum
foreach ( $color in $colors ) {
Write-Host (" {0,2} {1,$max} " -f [int]$color, $color) -NoNewline
Write-Host "$color" -Foreground $color
}
}
Register-ArgumentCompleter -Native -CommandName winget -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
$Local:word = $wordToComplete.Replace('"', '""')
$Local:ast = $commandAst.ToString().Replace('"', '""')
winget complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
Set-Alias -name "title" -value Set-WindowTitle
## Final Line to set prompt
# Starship
Invoke-Expression (&starship init powershell)