From 77548f44d74c8e3f4b5c3929c0365e442461f083 Mon Sep 17 00:00:00 2001
From: Josef Hofer <josef.hofer@1und1.de>
Date: Tue, 12 Nov 2024 10:35:15 +0100
Subject: [PATCH] fix/improve: project_selector

---
 hosts/shared/programs/kitty/default.nix | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/hosts/shared/programs/kitty/default.nix b/hosts/shared/programs/kitty/default.nix
index 1980de5c..3d57ac27 100644
--- a/hosts/shared/programs/kitty/default.nix
+++ b/hosts/shared/programs/kitty/default.nix
@@ -140,11 +140,6 @@
       "opt+shift+7" = "send_text all \\\\";  # backslash
       "opt+shift+-" = "send_text all —";  # em dash
     };
-
-    # Extra configuration to ensure catpuccin theme is included
-    # extraConfig = ''
-    #   include ${config.xdg.configHome}/kitty/themes/catpuccin.conf
-    # '';
   };
 
   xdg.configFile = {
@@ -163,17 +158,26 @@
     "kitty/scripts/project_selector.sh" = {
       text = ''
         #!/bin/bash
+        ghq_root=${vars.git.ghq}
         project_dirs=(${vars.kitty.project_selector})
-        # Display the subfolders of the project directories
+
+        # Function to find git repositories under the ghq root path
+        git_repos() {
+          find "$ghq_root" -type d -name ".git" | sed 's/\/.git$//'
+        }
+
+        # Display the git repositories and subfolders of the project directories
         projects() {
+          git_repos
           for dir in "$project_dirs[@]"; do
             find "$dir" -maxdepth 1 -type d | tail -n +2 # List subdirectories only, excluding the base directory itself
           done
         }
+
         # Select a project directory using fzf
         project_selector() {
           local project
-          project=$(projects | fzf)
+          project=$(projects | fzf --height 100%)
 
           if [ -n "$project" ]; then
             {
@@ -187,6 +191,7 @@
             echo "No project selected."
           fi
         }
+
         project_selector
       '';
     };