-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsync.ps1
More file actions
27 lines (23 loc) · 749 Bytes
/
Copy pathcsync.ps1
File metadata and controls
27 lines (23 loc) · 749 Bytes
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
# Sync cursor-sync: stage, commit if needed, pull --rebase, push.
# Dot-source from your profile: . "$env:USERPROFILE\cursor-sync\scripts\csync.ps1"
# Or run once: pwsh -File ./scripts/csync.ps1 "optional message"
function global:csync {
param([string]$msg = "sync $(Get-Date -Format o)")
$repo = if ($env:CURSOR_SYNC) { $env:CURSOR_SYNC } else { Split-Path $PSScriptRoot -Parent }
$repo = $repo.TrimEnd('\', '/')
Push-Location $repo
try {
git add -A
git diff --cached --quiet
if ($LASTEXITCODE -ne 0) {
git commit -m $msg | Out-Null
}
git pull --rebase --autostash --quiet
git push --quiet
} finally {
Pop-Location
}
}
if ($MyInvocation.InvocationName -ne '.') {
csync @args
}