From d26ecee2eeb98e84de405711c7445dfb8dba96f5 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.dev>
Date: Tue, 16 Apr 2024 18:05:55 +0100
Subject: [PATCH] Extract the remote URL from the repository URL

---
 lib/shared/modules/zsh.nix | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/shared/modules/zsh.nix b/lib/shared/modules/zsh.nix
index 93ee422a..6e784963 100644
--- a/lib/shared/modules/zsh.nix
+++ b/lib/shared/modules/zsh.nix
@@ -23,12 +23,17 @@
           [[ -z "$user" ]] && user="$USER"
         fi
 
+        # Extract the remote domain (e.g. github.com) from the repo URL.
+        domain="''${repo_url#*@}"
+        domain="''${domain%:*}"
+
         repo_name="''${user_and_repo_name##*/}"
         repo_name="''${repo_name%.git}"
 
-        user_path="''${HOME}/Code/github.com/''${user}"
+        user_path="''${HOME}/Code/''${domain}/''${user}"
 
         user_repo_path="''${user_path}/''${repo_name}"
+
         [[ -d "''${user_repo_path}" ]] && t "''${user_repo_path}" && return
 
         ${pkgs.coreutils}/bin/mkdir -p "''${user_path}"