#!/usr/bin/env nu # SPDX-License-Identifier: AGPL-3.0-only # Copyright (c) 2026 MatrixFurry const key_path: path = "~/.ssh/id_tangled_quick_setup" | path expand const pubkey_path: path = $key_path ++ ".pub" const config: path = "~/.ssh/config" | path expand # Easily and quickly set up Git and Jujutsu for Tangled. Sets up the following: # - SSH Key # - Commit signing # - Change ID headers export def main [] { print "Setting up Jujutsu change ID headers" let jj = (which jj | length) != 0 if $jj { jj config set --user git.write-change-id-header true } else { print "Jujustu is not installed, skipping" } print "Setting up SSH Key" let email = input "Enter your email, handle, or DID (can be found at https://tangled.org/settings): " ssh-keygen -t ed25519 -C $email -f $key_path touch ~/.ssh chmod 700 ~/.ssh touch $config chmod 600 $config [ "Host tangled.org knot1.tangled.sh" " User git" $" IdentityFile ($key_path)" " AddressFamily inet" ] | str join "\n" | save -a $config print "Finished setting up SSH key" let pubkey = open --raw $pubkey_path print $"IMPORTANT: Copy the key to your profile \(https://tangled.org/settings/keys\): `($pubkey)`" loop { match (input "Would you like to set up commit signing for Git and Jujutsu? This will override any existing commit signing settings. [y/N]: ") { "y" | "yes" => (break) "n" | "no" | "" | null => (exit) } } if $jj { jj config set --user signing.behavior "own" jj config set --user signing.backend "ssh" jj config set --user signing.key $key_path jj config set --user signing.backends.ssh.allowed-signers ".allowed_signers" jj config set --user signing.backends.ssh.revocation-list ".revoked_keys" print "Successfully set up commit signing for Jujutsu" } else { print "Jujustu is not installed, skipping" } git config set --global user.signingKey $key_path git config set --global gpg.format "ssh" git config set --global commit.gpgSign true print "Successfully set up commit signing for Git" }