From 8ec5210d70592339788eccf16df342c93db7c931 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Fri, 24 Nov 2023 17:25:51 -0600 Subject: [PATCH] feat: clone Signed-off-by: jolheiser --- apps/nogui/nushell/jolheiser.nu | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/apps/nogui/nushell/jolheiser.nu b/apps/nogui/nushell/jolheiser.nu index 6fbd8b3..0d6e4bc 100644 --- a/apps/nogui/nushell/jolheiser.nu +++ b/apps/nogui/nushell/jolheiser.nu @@ -25,6 +25,32 @@ def nixdev [ ^nu -c $cmd } +def "forge types" [] { + ["github", "gitea", "jojodev", "codeberg"] +} + +def clone [ + repo: string # Repo name + --forge (-f) = "github": string@"forge types" # Forge type (github, gitea, jojodev, codeberg) + --owner (-o): string # Owner (default: current dir name) +] { + let owner = ($env.PWD | path basename) + mut id = 'gh' + if $forge == 'gitea' { + $id = 'gt' + } else if $forge == 'jojodev' { + $id = 'jj' + } else if $forge == 'codeberg' { + $id = 'cb' + } + let origin = $'ssh:($id):jolheiser/($repo).git' + let upstream = $'($id):($owner)/($repo).git' + ^git clone $origin + cd $repo + ^git remote add upstream $upstream + ^git fetch upstream +} + ## Other ## $env.EDITOR = hx $env.config = ($env.config | upsert "shell_integration" ("WEZTERM_PANE" not-in $env and "SSH_CLIENT" not-in $env))