Something went wrong. Try again.
Small (but incredibly useful!) scripts and utilities that don't need their own repo.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435#!/usr/bin/env nu# SPDX-License-Identifier: AGPL-3.0-only# Copyright (c) 2025 MatrixFurry <matrix@matrixfurry.com>
use std/log
# Update symlink targets from an old target directory to a new one@example "If you moved `~/Development/tools` to `~/Applications/Development Tools`, update all symlinks in `~/.local/bin` that point to the old location" { relink ~/.local/bin ~/Development/tools `~/Applications/Development Tools`}@example "Update symlinks in `~/.local/bin` from target `~/Development/tools` to `~/Applications/Development Tools`" { relink ~/.local/bin ~/Development/tools `~/Applications/Development Tools`}export def main [ directory: path old_target_dir: path new_target_dir: path] { let directory = $directory | path expand let old_target_dir = $old_target_dir | path expand let new_target_dir = $new_target_dir | path expand
log info $"Updating symlinks in ($directory): ($old_target_dir)/.* -> ($new_target_dir)/.*"
ls -l $directory | where type == symlink and target starts-with $old_target_dir | par-each {|link| let new_target = $link.target | str replace ($old_target_dir + "/") ($new_target_dir + "/") ln -sf $new_target $link.name log info $"Updated ($link.name) target: ($link.target) -> ($new_target)" }
log info "Done!"}