From: Matthew Owens <matthew@owens.tech>
Date: Thu, 20 Jan 2022 16:37:00 +0000 (+0000)
Subject: updates
X-Git-Url: https://git.owens.tech/112-editable-focus.html/112-editable-focus.html/git?a=commitdiff_plain;h=a407476c38fdcd83fcdf257d54c01d183eebbcfa;p=scripts.git

updates
---

diff --git a/irc b/irc
new file mode 100755
index 0000000..2e9da2b
--- /dev/null
+++ b/irc
@@ -0,0 +1,4 @@
+#!/bin/bash
+#mosh matthew@owens.tech -- screen -dr
+#mosh sleepy@192.248.162.7 -- screen -dr
+ssh -t sleepy@192.248.162.7 screen -dr
diff --git a/proj b/proj
index a935215..e574e1e 100755
--- a/proj
+++ b/proj
@@ -11,26 +11,50 @@ fi
 
 folderPath=$(find $HOME/git/ -maxdepth 3 -type d -name $1)
 folderCount=$(find $HOME/git/ -maxdepth 3 -type d -name $1 | wc -l)
+running=$(tmux ls | grep $1 | wc  -l) # if 1 we have a session running already
 
-if [ $folderCount -gt 1 ]; then
-	echo "err: multiple possible projects found for '$1'"
-	echo $folderPath
-	exit
+if [ $folderCount -gt 1 ] && [ $running -ne 1 ]; then
+	count=1
+	echo "multiple possible projects found for '$1', pick one"
+
+	for var in $folderPath
+	do
+		echo -e "\t$count) '$var'"
+		((count++))
+	done
+
+	read -p "Enter a path number: " selected
+	while [[ $selected -lt 1 || $selected -gt $folderCount ]]; do
+		read -p "Bad value, try again: " selected
+	done
+
+	count=1
+	for var in $folderPath
+	do
+		if [[ $count -eq $selected ]]; then
+			path=$var
+		fi
+		((count++))
+	done
+	echo "selected: $path"
 elif [ $folderCount -eq 0 ]; then
 	echo "err: no possible projects found for '$1'"
 	exit
+else
+	path=$folderPath
 fi
  
 # is the session already running?
-if [ $(tmux ls | grep $1 | wc  -l) -eq 1 ]; then
+if [ $running -eq 1 ]; then
 	tmux new-session -A -s $1
 	exit
 else
-	cd $folderPath
+	cd $path
 	tmux new-session -d -s $1
+	#tmux new-session -A -s $1
 	tmux rename-window src
 	tmux send-keys "cd src;clear" ENTER
-	tmux new-window -n build -c $folderPath
+	tmux new-window -n build -c $path
 	tmux select-window -t src
 	tmux -2 attach-session -d
 fi