-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall-Profile.ps1
More file actions
66 lines (54 loc) · 2.17 KB
/
Copy pathInstall-Profile.ps1
File metadata and controls
66 lines (54 loc) · 2.17 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
# PowerShell 7 Enhanced Profile Installer
# This script installs the enhanced PowerShell profile
param(
[switch]$Force,
[switch]$Backup
)
Write-Host "🚀 PowerShell 7 Enhanced Profile Installer" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
# Check if PowerShell 7
if ($PSVersionTable.PSVersion.Major -lt 7) {
Write-Error "This profile requires PowerShell 7 or later. Current version: $($PSVersionTable.PSVersion)"
exit 1
}
# Get profile path
$ProfilePath = $PROFILE
Write-Host "Profile location: $ProfilePath" -ForegroundColor Yellow
# Backup existing profile if requested
if ($Backup -and (Test-Path $ProfilePath)) {
$BackupPath = "$ProfilePath.backup.$(Get-Date -Format 'yyyyMMdd-HHmmss')"
Copy-Item $ProfilePath $BackupPath
Write-Host "✅ Backup created: $BackupPath" -ForegroundColor Green
}
# Check if profile already exists
if ((Test-Path $ProfilePath) -and -not $Force) {
$response = Read-Host "Profile already exists. Overwrite? (y/N)"
if ($response -ne 'y' -and $response -ne 'Y') {
Write-Host "❌ Installation cancelled." -ForegroundColor Red
exit 0
}
}
# Install the enhanced profile
try {
$EnhancedProfilePath = Join-Path $PSScriptRoot "enhanced-profile.ps1"
if (-not (Test-Path $EnhancedProfilePath)) {
Write-Error "Enhanced profile file not found: $EnhancedProfilePath"
exit 1
}
# Create profile directory if it doesn't exist
$ProfileDir = Split-Path $ProfilePath -Parent
if (-not (Test-Path $ProfileDir)) {
New-Item -ItemType Directory -Path $ProfileDir -Force | Out-Null
}
# Copy the enhanced profile
Copy-Item $EnhancedProfilePath $ProfilePath -Force
Write-Host "✅ Enhanced profile installed successfully!" -ForegroundColor Green
# Reload the profile
Write-Host "🔄 Reloading profile..." -ForegroundColor Yellow
. $PROFILE
Write-Host "🎉 Installation complete! Your PowerShell experience is now enhanced." -ForegroundColor Green
Write-Host "💡 Type 'Show-GitAliases' to see available Git shortcuts." -ForegroundColor Cyan
} catch {
Write-Error "Failed to install profile: $_"
exit 1
}