feat(windows): добавлены proxy-хелперы и упрощен git baseline

- Зачем:
  - нужно перенести привычные proxy_on/proxy_off/myip из bash в pwsh и убрать устаревший codevpn.
  - нужно сделать Windows Git baseline проще и предсказуемее, чтобы effective значения и проверки не путались.
- Что:
  - в managed profile PowerShell 7 добавлены `proxy_on`, `proxy_off`, `myip` и удалён `codevpn`.
  - Git baseline перенесён в `~/.gitconfig`, а `~/.gitconfig.local` оставлен только для локальных и персональных override-настроек.
  - README уточнён: legacy-статус Windows PowerShell 5.1, новые helper-функции и корректная команда проверки Git-конфига.
- Проверка:
  - `chezmoi -S "$HOME\dotfiles\chezmoi" apply --force`
  - `pwsh -NoLogo -Command ''Get-Command proxy_on,proxy_off,myip,Reload-Profile,wt-here; Test-Path function:codevpn''`
  - `git config --global --includes --list --show-origin`
This commit is contained in:
Dmitry Dementiev committed 2026-03-22 15:58:10 +03:00
1 parent 8fd5b9c630
commit 9b66fc70fc
5 files changed
+119 -36

No files matched your search

@@ -5,13 +5,38 @@ if (-not $IsWindows) {
$GlobalGitConfig = Join-Path $HOME '.gitconfig'
$LocalGitConfig = Join-Path $HOME '.gitconfig.local'
$BackupPath = '{0}.pre-chezmoi.bak-{1}' -f $GlobalGitConfig, (Get-Date -Format 'yyyyMMdd-HHmmss')
$ManagedStub = @'
$ManagedStubs = @(
@'
[core]
autocrlf = false
eol = lf
quotepath = false
longpaths = true
[fetch]
prune = true
[pull]
ff = only
[init]
defaultBranch = main
[include]
path = ~/.gitconfig.local
'@,
@'
[include]
path = ~/.gitconfig.local
'@,
@'
[include]
path = ~/.config/git/config
[include]
path = ~/.gitconfig.local
'@
)
$ManagedKeys = @(
'core.autocrlf',
@@ -30,8 +55,14 @@ function Test-ManagedGitStub {
)
$NormalizedContent = ($Content -replace "`r", '').Trim()
$NormalizedStub = ($ManagedStub -replace "`r", '').Trim()
return $NormalizedContent -eq $NormalizedStub
foreach ($ManagedStub in $ManagedStubs) {
$NormalizedStub = ($ManagedStub -replace "`r", '').Trim()
if ($NormalizedContent -eq $NormalizedStub) {
return $true
}
}
return $false
}
if (-not (Test-Path -LiteralPath $GlobalGitConfig)) {
-14
View File
@@ -1,14 +0,0 @@
[core]
autocrlf = false
eol = lf
quotepath = false
longpaths = true
[fetch]
prune = true
[pull]
ff = only
[init]
defaultBranch = main
+64 -15
View File
@@ -82,6 +82,70 @@ function croot {
Set-Location -Path $Root.Trim()
}
function Get-PublicIp {
$CurlExe = Get-Command curl.exe -ErrorAction SilentlyContinue
if ($null -ne $CurlExe) {
try {
$CurrentIp = & $CurlExe.Source --silent --show-error --max-time 3 https://ifconfig.me/ip
return ([string]$CurrentIp).Trim()
}
catch {
return $null
}
}
try {
return ([string](Invoke-RestMethod -Uri 'https://ifconfig.me/ip' -TimeoutSec 3)).Trim()
}
catch {
return $null
}
}
function proxy_on {
$ProxyHost = 'hproxy.local'
$ProxyPort = 12334
$env:HTTP_PROXY = 'http://{0}:{1}' -f $ProxyHost, $ProxyPort
$env:HTTPS_PROXY = 'http://{0}:{1}' -f $ProxyHost, $ProxyPort
$env:ALL_PROXY = 'socks5://{0}:{1}' -f $ProxyHost, $ProxyPort
$env:NO_PROXY = '{0},localhost,127.0.0.1,.concept-software.ru' -f $ProxyHost
'Proxy enabled. Checking route...'
$CurrentIp = Get-PublicIp
if ([string]::IsNullOrWhiteSpace($CurrentIp)) {
'Current IP: unavailable'
}
else {
'Current IP: {0}' -f $CurrentIp
}
}
function proxy_off {
foreach ($VariableName in 'HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY', 'NO_PROXY') {
Remove-Item -Path ('Env:{0}' -f $VariableName) -ErrorAction SilentlyContinue
}
'Proxy disabled. Checking route...'
$CurrentIp = Get-PublicIp
if ([string]::IsNullOrWhiteSpace($CurrentIp)) {
'Current IP: unavailable'
}
else {
'Current IP: {0}' -f $CurrentIp
}
}
function myip {
$CurrentIp = Get-PublicIp
if ([string]::IsNullOrWhiteSpace($CurrentIp)) {
'IP: unavailable'
}
else {
'IP: {0}' -f $CurrentIp
}
}
if (Get-Command wt -ErrorAction SilentlyContinue) {
function wt-here {
wt -d (Get-Location).ProviderPath
@@ -96,21 +160,6 @@ if (Get-Command wt -ErrorAction SilentlyContinue) {
}
}
function codevpn {
$PreviousHttpProxy = $env:HTTP_PROXY
$PreviousHttpsProxy = $env:HTTPS_PROXY
try {
$env:HTTP_PROXY = 'http://127.0.0.1:12334'
$env:HTTPS_PROXY = 'http://127.0.0.1:12334'
code .
}
finally {
$env:HTTP_PROXY = $PreviousHttpProxy
$env:HTTPS_PROXY = $PreviousHttpsProxy
}
}
# Keep stable hooks for machine-local overrides and future managed fragments.
$ExtraProfile = Join-Path $HOME '.config\powershell\profile.extra.ps1'
if (Test-Path -LiteralPath $ExtraProfile) {
+14 -2
View File
@@ -1,5 +1,17 @@
[include]
path = ~/.config/git/config
[core]
autocrlf = false
eol = lf
quotepath = false
longpaths = true
[fetch]
prune = true
[pull]
ff = only
[init]
defaultBranch = main
[include]
path = ~/.gitconfig.local