Skip to content

Commit 6b0bf46

Browse files
committed
feat: re-structure and enhance profile segmentations
1 parent 5870807 commit 6b0bf46

3 files changed

+6
-61
lines changed

Microsoft.PowerShell_profile.ps1

+2-31
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,5 @@
44
# Current User, Current Host Powershell Core v7 $PROFILE:
55
# -------------------------------------------------------
66

7-
# Trust PSGallery
8-
$galleryinfo = Get-PSRepository | Where-Object { $_.Name -eq "PSGallery" }
9-
if (-not($galleryinfo.InstallationPolicy.Equals("Trusted"))) { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted }
10-
11-
# Default Parameters
12-
$PSDefaultParameterValues = @{
13-
"Update-Module:Confirm"=$False;
14-
"Update-Module:Force"=$True;
15-
"Update-Module:Scope"="CurrentUser";
16-
"Update-Module:ErrorAction"="SilentlyContinue";
17-
"Update-Help:Force"=$True;
18-
"Update-Help:ErrorAction"="SilentlyContinue"
19-
}
20-
21-
$psdir = (Split-Path -Parent $profile)
22-
23-
# Load Functions, Aliases, Completions, and Modules
24-
If (Test-Path "$psdir\Profile\functions.ps1") { . "$psdir\Profile\functions.ps1" }
25-
If (Test-Path "$psdir\Profile\aliases.ps1") { . "$psdir\Profile\aliases.ps1" }
26-
If (Test-Path "$psdir\Profile\completion.ps1") { . "$psdir\Profile\completion.ps1" }
27-
If (Test-Path "$psdir\Profile\modules.ps1") { . "$psdir\Profile\modules.ps1" }
28-
29-
# Set PSReadLineOptions's (Beta Version Required):
30-
If (!(!((Get-Module -Name PSReadLine).Version.Major -ge 2)) -and (!(Get-Module -Name PSReadLine).Version.Minor -ge 2)) {
31-
Install-Module -Name PSReadLine -AllowPrerelease -Force -AllowClobber -Scope CurrentUser
32-
}
33-
Set-PSReadLineOption -PredictionSource History -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
34-
Set-PSReadLineOption -PredictionViewStyle ListView -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
35-
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
36-
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
37-
Set-PSReadlineOption -EditMode Windows
7+
# Load Custom User Specific Functions Here:
8+
# . Custom\*.ps1

Microsoft.VSCode_profile.ps1

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@
44
# Current User, Current Host Powershell Core v7 $PROFILE:
55
# -------------------------------------------------------
66

7-
$psdir = (Split-Path -Parent $profile)
8-
9-
. "$psdir\Profile\functions.ps1"
10-
. "$psdir\Profile\aliases.ps1"
11-
. "$psdir\Profile\completion.ps1"
12-
. "$psdir\Profile\modules.ps1"
7+
# Load Custom VSCode Specific Functions Here:
8+
# . Custom\*.ps1

profile.ps1

+2-24
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,5 @@
44
# Current User, All Hosts Powershell Core v7 $PROFILE:
55
# ----------------------------------------------------
66

7-
# Trust PSGallery
8-
$galleryinfo = Get-PSRepository | Where-Object { $_.Name -eq "PSGallery" }
9-
if (-not($galleryinfo.InstallationPolicy.Equals("Trusted"))) { Set-PSRepository -Name PSGallery -InstallationPolicy Trusted }
10-
11-
# Default Parameters
12-
$PSDefaultParameterValues = @{
13-
"Update-Module:Confirm"=$False;
14-
"Update-Module:Force"=$True;
15-
"Update-Module:Scope"="CurrentUser";
16-
"Update-Module:ErrorAction"="SilentlyContinue";
17-
"Update-Help:Force"=$True;
18-
"Update-Help:ErrorAction"="SilentlyContinue"
19-
}
20-
21-
# Prompt
22-
Set-PoshPrompt -Theme wopian -ErrorAction SilentlyContinue
23-
24-
# Write Current Version and Execution Policy Details:
25-
Write-Host "PowerShell Version: $($psversiontable.psversion) - ExecutionPolicy: $(Get-ExecutionPolicy)" -ForegroundColor yellow
26-
27-
# ZLocation must be after all prompt changes:
28-
Import-Module ZLocation
29-
Write-Host -Foreground Green "`n[ZLocation] knows about $((Get-ZLocation).Keys.Count) locations.`n"
30-
7+
$psfiles = Join-Path (Split-Path -Parent $profile) "Profile" | Get-ChildItem -Filter "*.ps1"
8+
ForEach ($file in $psfiles) { . $file }

0 commit comments

Comments
 (0)