Skip to content

Commit bb06eca

Browse files
committed
Added support for customizing remote repository. Enabled profile functions and filters starting with _ (underscore).
1 parent fa5c090 commit bb06eca

6 files changed

+33
-4
lines changed

Microsoft.PowerShell_profile.ps1

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1.0.7945.36516
1+
# 1.0.8030.24604
22

33
## $Env:PATH management
44
Function Add-DirectoryToPath {
@@ -118,6 +118,19 @@ if (-not (Get-Module -Name Pwsh-Profile -ListAvailable)) {
118118
Write-Host " Install-Module -Name Pwsh-Profile -Repository PSGallery -Scope CurrentUser -Force" -ForegroundColor DarkGray
119119

120120
return
121+
} else {
122+
123+
$update8030 = Join-Path -Path (Get-CachedPowerShellProfileFolder) -ChildPath "pwsh_profile_8030"
124+
if (-not (Test-Path $update8030)){
125+
$online = Find-Module -Name Pwsh-Profile -Repository PSGallery
126+
$current = Get-module -Name Pwsh-Profile -ListAvailable
127+
if ($online.Version -gt $current.Version) {
128+
Write-Host "Required 'Pwsh-Profile' module has updates." -ForegroundColor Yellow
129+
Write-Host "Please, update this module using the following command:" -ForegroundColor Yellow
130+
Write-Host " Update-Module -Name Pwsh-Profile -Force" -ForegroundColor DarkGray
131+
}
132+
Set-Content -Path $update8030 -Value $null
133+
}
121134
}
122135

123136
CheckFor-ProfileUpdate | Out-Null

Pwsh-Profile/Get-ProfilePath.psm1

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ Function Get-ProfilePath {
2020
$pattern = (Split-Path $profile -Leaf)
2121

2222
$template = "Microsoft.PowerShell_%{NAME}%profile.ps1"
23-
$address = "https://raw.githubusercontent.com/springcomp/powershell_profile.ps1/master/"
23+
$DEFAULT_REMOTE_REPOSITORY = "https://raw.githubusercontent.com/springcomp/powershell_profile.ps1/master/"
24+
$address = $Env:PWSH_PROFILES_REMOTE_REPOSITORY
25+
if (-not $address) {
26+
$address = $DEFAULT_REMOTE_REPOSITORY
27+
}
2428
}
2529

2630
PROCESS {

Pwsh-Profile/Load-Profile.psm1

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Function Load-Profile {
1717
## Using [IO.File]::ReadAllText() instead of Get-Content -Raw for performance purposes
1818

1919
$content = [IO.File]::ReadAllText($path)
20-
$content = $content -replace "(?<!\-)[Ff]unction\ +([A-Za-z]+)", 'Function global:$1'
20+
$content = $content -replace "(?<!\-)[Ff]unction\ +([_A-Za-z]+)", 'Function global:$1'
21+
$content = $content -replace "(?<!\-)[Ff]ilter\ +([_A-Za-z]+)", 'Filter global:$1'
2122
$content = $content -replace "[Ss][Ee][Tt]\-[Aa][Ll][Ii][Aa][Ss]\ +(.*)", 'Set-Alias -Scope Global $1'
2223

2324
Write-Output $content

Pwsh-Profile/Pwsh-Profile.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
RootModule = 'Load-Profile.psm1'
3-
ModuleVersion = '1.0.7947'
3+
ModuleVersion = '1.0.8030'
44
GUID = '3b9dc291-4855-4402-8721-ff45cacd0a10'
55
Author = 'SpringComp'
66
Description = 'Manage extensible PowerShell profiles using simple CmdLets'

Pwsh-Profile/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Pwsh-Profile module
2+
3+
To install, run the following command:
4+
5+
```pwsh
6+
Publish-Module -Name Pwsh-Profile -NuGetApiKey <apiKey>
7+
```

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Then open a PowerShell prompt or reload your profile.
1414
Install-Module -Name Pwsh-Profile -Repository PSGallery -Scope CurrentUser -Force
1515
```
1616

17+
**Notice**: If you want to clone this repository and have you own versions of the default profiles, please set the `$Env:PWSH_PROFILES_REMOTE_REPOSITORY` environment variable to point to the root path of the raw scripts in your repository. Please, see the documentation for the CmdLets available below for more details.
18+
1719
## Customize your prompt with Oh-My-Posh
1820

1921
```pwsh
@@ -76,3 +78,5 @@ Starting from version 1.0.7945, all functions from the main profile script have
7678
|`Install-Profile`|Downloads the specified profile and registers its loading in the `Microsoft.PowerShell_profiles-profile.ps1` script.|
7779
|`Load-Profile`|Loads a named profile. See `Microsof.PowerShell_profiles-profile.ps1`.|
7880
|`Update-Profile`|Replaces the specified local profile by the content from the corresponding remote profile script. Supports a `-all` flag to update all profiles in one fell swoop.|
81+
82+
To customize the location of the remote Powershell Profiles repository, you can set the `$Env:PWSH_PROFILES_REMOTE_REPOSITORY` environment variable to the root path of raw scripts files in your repository. If the variable is not set, the default value is the string `https://raw.githubusercontent.com/springcomp/powershell_profile.ps1/master/`.

0 commit comments

Comments
 (0)