86 lines
3.3 KiB
PowerShell
86 lines
3.3 KiB
PowerShell
# bootstrap.ps1 — Установка профиля PS gper
|
|||
|
|
# Версия: 1.0.0
|
||
|
|
# Дата: 2026-07-21
|
||
|
|
# Запуск с любой машины:
|
||
|
|
# iwr 'https://sc.gper.ru/tarakan/ps-profile/raw/branch/main/bootstrap.ps1' | iex
|
||
|
|
|
||
|
|
# ============================================
|
||
|
|
# КОНФИГУРАЦИЯ
|
||
|
|
# ============================================
|
||
|
|
$PROFILE_REPO = 'https://sc.gper.ru/tarakan/ps-profile.git'
|
||
|
|
$PROFILE_DIR = Join-Path $HOME 'Documents\PowerShell\gper-profile'
|
||
|
|
$MODULES = @(
|
||
|
|
'PSReadLine',
|
||
|
|
'Terminal-Icons',
|
||
|
|
'Posh-SSH',
|
||
|
|
'Microsoft.PowerShell.SecretManagement',
|
||
|
|
'Microsoft.PowerShell.SecretStore',
|
||
|
|
'TableUI'
|
||
|
|
)
|
||
|
|
|
||
|
|
# ============================================
|
||
|
|
# BOOTSTRAP
|
||
|
|
# ============================================
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host '=== Bootstrap: gper PS Profile ===' -ForegroundColor Cyan
|
||
|
|
Write-Host ''
|
||
|
|
|
||
|
|
# 1. Execution Policy
|
||
|
|
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
|
||
|
|
Write-Host '[OK] ExecutionPolicy = RemoteSigned' -ForegroundColor Green
|
||
|
|
|
||
|
|
# 2. PSResourceGet — современный установщик модулей
|
||
|
|
if (-not (Get-Module Microsoft.PowerShell.PSResourceGet -ListAvailable -ErrorAction SilentlyContinue)) {
|
||
|
|
Write-Host '[..] Устанавливаю PSResourceGet...' -ForegroundColor Yellow -NoNewline
|
||
|
|
Install-Module Microsoft.PowerShell.PSResourceGet -Scope CurrentUser -Force -AllowClobber
|
||
|
|
Write-Host ' готово' -ForegroundColor Green
|
||
|
|
}
|
||
|
|
|
||
|
|
# 3. Модули
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host '--- Модули ---' -ForegroundColor Cyan
|
||
|
|
foreach ($mod in $MODULES) {
|
||
|
|
if (Get-Module $mod -ListAvailable -ErrorAction SilentlyContinue) {
|
||
|
|
Write-Host "[OK] $mod" -ForegroundColor Green
|
||
|
|
} else {
|
||
|
|
Write-Host "[..] $mod..." -ForegroundColor Yellow -NoNewline
|
||
|
|
Install-PSResource -Name $mod -Scope CurrentUser -TrustRepository -Quiet -ErrorAction SilentlyContinue
|
||
|
|
Write-Host ' установлен' -ForegroundColor Green
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
# 4. Клонировать / обновить репо профиля
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host '--- Репо профиля ---' -ForegroundColor Cyan
|
||
|
|
if (Test-Path (Join-Path $PROFILE_DIR '.git')) {
|
||
|
|
Write-Host '[..] Обновляю репо...' -ForegroundColor Yellow -NoNewline
|
||
|
|
Push-Location $PROFILE_DIR
|
||
|
|
git pull --quiet
|
||
|
|
Pop-Location
|
||
|
|
Write-Host ' готово' -ForegroundColor Green
|
||
|
|
} else {
|
||
|
|
if (Test-Path $PROFILE_DIR) { Remove-Item $PROFILE_DIR -Recurse -Force }
|
||
|
|
Write-Host '[..] Клонирую профиль...' -ForegroundColor Yellow -NoNewline
|
||
|
|
git clone --quiet $PROFILE_REPO $PROFILE_DIR
|
||
|
|
Write-Host ' готово' -ForegroundColor Green
|
||
|
|
}
|
||
|
|
|
||
|
|
# 5. Подключить в $PROFILE (CurrentUserCurrentHost)
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host '--- Профиль ---' -ForegroundColor Cyan
|
||
|
|
$profileLine = ". `"$PROFILE_DIR\profile.ps1`""
|
||
|
|
if (-not (Test-Path $PROFILE)) {
|
||
|
|
New-Item -Path $PROFILE -ItemType File -Force | Out-Null
|
||
|
|
}
|
||
|
|
$profileContent = Get-Content $PROFILE -Raw -ErrorAction SilentlyContinue
|
||
|
|
if ($profileContent -notmatch 'gper-profile') {
|
||
|
|
Add-Content -Path $PROFILE -Value "`n$profileLine"
|
||
|
|
Write-Host "[OK] Подключён: $PROFILE" -ForegroundColor Green
|
||
|
|
} else {
|
||
|
|
Write-Host '[OK] Уже подключён' -ForegroundColor Yellow
|
||
|
|
}
|
||
|
|
|
||
|
|
Write-Host ''
|
||
|
|
Write-Host '=== Готово! Перезапусти терминал ===' -ForegroundColor Cyan
|
||
|
|
Write-Host ''
|