Something went wrong. Try again.
Small (but incredibly useful!) scripts and utilities that don't need their own repo.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#!/usr/bin/env nu# SPDX-License-Identifier: AGPL-3.0-only# Copyright (c) 2026 MatrixFurry <matrix@matrixfurry.com>
use std/log
const config_path: path = ".rawrsync.toml"
# Easily sync or deploy projects using `rsync`. Intended to somewhat replicate CLion's Deployment feature for use with other IDEs.## Configure with `.rawrsync.toml` in your project root. For example:# ```toml# [org-server-23]# user = "username"# address = "org-server-23.tailnet-name.ts.net"# path = "/home/username/deployment/project/" # Destination path on the server## [vr-desktop]# user = "username"# address = "vr-desktop.tailnet-name.ts.net"# path = "/home/username/vr/project"# ```export def main [ select?: string # Select a configuration by name --continuous (-c) # Sync on file change --verbose (-v) # Verbose rsync logging (use NU_LOG_LEVEL=debug to set rawrsync logging level)] { if not ($config_path | path exists) { log critical $"Could not find configuration file in current directory \(($config_path)\)" exit 1 }
let src: path = pwd | path expand
let config = open $config_path | transpose name data
let dest: record<user, address, path> = if ($config | length) == 1 { $config | get 0.data } else if ($select | is-not-empty) { let selected_entry = $config | where name == $select
if ($selected_entry | length) < 1 { log critical $"Could not find selected configuration \"($select)\"" exit 1 }
$selected_entry | get 0.data } else { $config | input list -d name "Sync to..." | get data }
if $continuous { # TODO: only run rsync on changed files watch --verbose $src {|| sync --verbose=$verbose $src $dest} } else { sync --verbose=$verbose $src $dest }}
def sync [ src: path dest: record<user, address, path> --verbose (-v)] { let args = [ -zar # Compress, archive (preserve permissions etc.), recursive (if $verbose {"-v"} else {""}) --exclude=.svn --exclude=.cvs --exclude=.DS_Store --exclude=.git --exclude=.hg --exclude=*.hprof --exclude=*.pyc --exclude=.jj --exclude=.idea --exclude=.zed --exclude=.rawrsync.toml --delete ($src ++ "/") # make sure the source directory path ends with a / $"($dest.user)@($dest.address)://($dest.path)" ] | where ($it | is-not-empty)
log info $"Syncing to ($dest.address)" log debug $"Sync ($src) to ($dest.path) using rsync" log debug $"rsync ($args | str join ' ')" rsync ...$args}