From 3d24bce0d967ff4418a6f7aba3a211c8e55f06ea Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Thu, 25 Jan 2024 18:18:16 +0000
Subject: [PATCH] Don't show any directories ending in "-old"

---
 bin/t | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/bin/t b/bin/t
index 2d916534..7d589acc 100755
--- a/bin/t
+++ b/bin/t
@@ -10,11 +10,30 @@ if [[ $# -eq 1 ]]; then
 else
   # Get the session name from fuzzy-finding list of directories and generating a
   # tmux-safe version.
-  items+=$(find "${HOME}/Code" -mindepth 3 -maxdepth 3 -type d ! -name .git -not -path "${HOME}/Code/tmp/*")
-  items+=" "
-  items+=$(find "${HOME}/Code/tmp" -mindepth 1 -maxdepth 1 -type d)
 
-  selected=$(echo "${items}" | sort | fzf --reverse)
+  # Find all project directories within ~/Code, ignoring ~/Code/tmp as those
+  # are only at a single level and I don't want sub-directories within those
+  # directories to be shown.
+  items+=$(find "${HOME}/Code" \
+    -maxdepth 3 \
+    -mindepth 3 \
+    -type d \
+    ! -name "*-old" \
+    ! -name "*.old" \
+    ! -path "${HOME}/Code/tmp/*"
+  )
+
+  # Add the top-level directories within ~/Code/tmp.
+  items+=" "
+  items+=$(find "${HOME}/Code/tmp" \
+    -maxdepth 1  \
+    -mindepth 1 \
+    -type d \
+    ! -name "*-old" \
+    ! -name "*.old"
+  )
+
+  selected=$(echo "${items}" | tr ' ' "\n" | sort | fzf --reverse)
 fi
 
 if [[ -z "${selected}" ]]; then