69 lines
2.7 KiB
PowerShell
69 lines
2.7 KiB
PowerShell
# Xenith PowerShell Activation Script
|
|
# Минималистичная версия: только PATH и алиасы для инструментов
|
|
|
|
# 1. Устанавливаем переменную для промпта
|
|
$env:VIRTUAL_ENV_PROMPT = "Xenith"
|
|
|
|
# 2. Добавляем локальные инструменты в начало PATH текущей сессии
|
|
# Приоритет отдается ./tools/, затем ./tools/cmake/bin/
|
|
$projectRoot = $PSScriptRoot
|
|
$toolsPath = Join-Path $projectRoot "tools"
|
|
$cmakeBinPath = Join-Path $toolsPath "cmake" "bin"
|
|
|
|
if (Test-Path $cmakeBinPath) {
|
|
$env:Path = "$cmakeBinPath;$toolsPath;$env:Path"
|
|
} elseif (Test-Path $toolsPath) {
|
|
$env:Path = "$toolsPath;$env:Path"
|
|
}
|
|
|
|
# 3. Алиасы для быстрых команд проекта
|
|
function global:Xenith { & "./bin/Xenith.exe" @args }
|
|
function global:Build_Shaders { python ./tools/build_shaders.py @args }
|
|
function global:Gen_Shaders { python ./tools/gen_shaders.py @args }
|
|
|
|
# 4. Настройка промпта
|
|
if (-not (Test-Path variable:_OLD_VIRTUAL_PS1)) {
|
|
$global:_old_fish_prompt = $function:prompt
|
|
$global:_OLD_VIRTUAL_PS1 = $true
|
|
|
|
function global:prompt {
|
|
Write-Host "(Xenith) " -NoNewline -ForegroundColor Red
|
|
& $global:_old_fish_prompt
|
|
}
|
|
}
|
|
|
|
# 5. Функция деактивации (полный откат состояния)
|
|
function global:deactivate {
|
|
Remove-Item function:Xenith, function:Build_Shaders, function:Gen_Shaders -ErrorAction SilentlyContinue
|
|
|
|
if (Test-Path variable:_old_fish_prompt) {
|
|
$function:prompt = $global:_old_fish_prompt
|
|
Remove-Item variable:_old_fish_prompt -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
Remove-Item env:VIRTUAL_ENV_PROMPT, variable:_OLD_VIRTUAL_PS1 -ErrorAction SilentlyContinue
|
|
|
|
if (Test-Path function:builtin_deactivate) { & builtin_deactivate }
|
|
|
|
Remove-Item function:deactivate -ErrorAction SilentlyContinue
|
|
Write-Host "Xenith deactivated" -ForegroundColor Yellow
|
|
}
|
|
|
|
# 6. Автодополнение для команды Xenith
|
|
if (Test-Path "./_xenith.ps1") {
|
|
. "./_xenith.ps1"
|
|
} else {
|
|
Register-ArgumentCompleter -CommandName Xenith -ScriptBlock {
|
|
param($wordToComplete, $commandAst, $cursorPosition)
|
|
$commands = @("new", "train", "fine-tune", "gen", "chat",
|
|
"ollama", "info", "gradcheck", "bench",
|
|
"update", "devices", "doctor", "config")
|
|
foreach ($cmd in $commands) {
|
|
if ($cmd -like "$wordToComplete*") {
|
|
[System.Management.Automation.CompletionResult]::new($cmd, $cmd, 'ParameterValue', $cmd)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host "Xenith environment activated" -ForegroundColor Green |