PowerShell-Profile/RdzeN-Profile.ps1
Tomasz Kostrzewa bf9d2489eb modified: RdzeN-Profile.ps1
modified:   functions/Test-Profile.ps1
2024-03-05 19:05:00 +01:00

74 lines
2.3 KiB
PowerShell

# gitea.RdzeN.net
#
# Example Powershell Profile.
#
# 1. Check if GITEA folder exists.
$path_gitea = "$($env:USERPROFILE)\GITEA"
$path_gitea_powershell_profile = "$path_gitea\PowerShell-Profile"
$path_gitea_powershell_profile_functions = "$path_gitea_powershell_profile\functions"
if (-not (Test-Path $path_gitea)) {
New-Item -ItemType Directory -Path $path_gitea | Out-Null
}
if (-not (Test-Path $path_gitea_powerShell_profile )) {
New-Item -ItemType Directory -Path $path_gitea_powerShell_profile | Out-Null
}
if (-not (Test-Path $path_gitea_powershell_profile_functions )) {
New-Item -ItemType Directory -Path $path_gitea_powershell_profile_functions | Out-Null
}
# 2. Download / pull GIT REPO
$RepositoryURL = "https://gitea.rdzen.net/najlepszytomasz/PowerShell-Profile.git"
if (-not (Get-ChildItem $path_gitea_powershell_profile_functions).count -gt 0) {
Set-Location $path_gitea
Write-Host "Creating GIT clone for: $RepositoryURL" -ForegroundColor Yellow
try {
git clone $RepositoryURL -q
Write-Host "Success GIT clone for: $RepositoryURL" -ForegroundColor Green
} catch {
Write-Host "Error occured while GIT clone for: $RepositoryURL" -ForegroundColor Red
}
} else {
Set-Location $path_gitea_powershell_profile
Write-Host "Pulling GIT for: $RepositoryURL" -ForegroundColor Yellow
try {
git pull -q
Write-Host "Success GIT pull for: $RepositoryURL" -ForegroundColor Green
} catch {
Write-Host "Error occured while GIT pull for: $RepositoryURL" -ForegroundColor Red
}
}
# 3. dot source functions.
Get-ChildItem $path_gitea_powershell_profile_functions | ForEach-Object {
Import-Module $_.FullName
}
# 96. Update Profile Section:
if (-not (Test-Path $PROFILE)) {
# 97. Test Profile
Test-Profile
} else {
# 98. Override Profile
do {
New-SimulateTyping "Do you want to Override your PS Profile?"
$reload = Read-Host "Type [Y]es or [N]o"
} until (
$reload -in ("Y","N")
)
if ($reload -eq "Y") {
Override-Profile
}
}
# 99. Reload Profile
do {
New-SimulateTyping "Do you want to Reload your PS Profile?"
$reload = Read-Host "Type [Y]es or [N]o"
} until (
$reload -in ("Y","N")
)
if ($reload -eq "Y") {
Reload-Profile
}