0
0
Prechádzať zdrojové kódy

feat(tmux): update `project_launch.zsh` to reuse windows

Joe 1 rok pred
rodič
commit
5e56b09f4b
3 zmenil súbory, kde vykonal 28 pridanie a 15 odobranie
  1. 5 3
      .scripts/nvim_launch.zsh
  2. 1 1
      .scripts/omnibar.zsh
  3. 22 11
      .scripts/project_launch.zsh

+ 5 - 3
.scripts/nvim_launch.zsh

@@ -1,7 +1,9 @@
 #!/bin/zsh
 #!/bin/zsh
-P=${1:-$( HOME )}
-tmux rename-window $(basename $P);
-cd $P
+
+if [ -n $1 ]; then
+    cd $1
+fi;
+
 while true; do;
 while true; do;
     if [ -f ./.venv/bin/activate ]; then
     if [ -f ./.venv/bin/activate ]; then
         source ./.venv/bin/activate
         source ./.venv/bin/activate

+ 1 - 1
.scripts/omnibar.zsh

@@ -5,7 +5,7 @@ tmux display-menu -t . \
     "Command List" "r" "list-commands" \
     "Command List" "r" "list-commands" \
     "Select Pane" "s" "choose-tree" \
     "Select Pane" "s" "choose-tree" \
     ""  \
     ""  \
-    "Open Project" "p" "new-window /bin/zsh ~/.scripts/project_launch.zsh" \
+    "Open Project" "p" "new-window -c ~ -n 'Project Launcher' timeout 60s /bin/zsh ~/.scripts/project_launch.zsh" \
     "Open Shell" "o" "new-window /bin/zsh" \
     "Open Shell" "o" "new-window /bin/zsh" \
     "Open Omniscratch" "u" "new-window /bin/zsh ~/.scripts/omniscratch.zsh" \
     "Open Omniscratch" "u" "new-window /bin/zsh ~/.scripts/omniscratch.zsh" \
     "Launch SSH" "v" "new-window /bin/zsh ~/.scripts/ssh_launch.zsh" \
     "Launch SSH" "v" "new-window /bin/zsh ~/.scripts/ssh_launch.zsh" \

+ 22 - 11
.scripts/project_launch.zsh

@@ -1,12 +1,23 @@
 #!/bin/zsh
 #!/bin/zsh
-tmux new-window \
-    /bin/zsh ~/.scripts/nvim_launch.zsh \
-   $( \
-        fd \
-            --base-directory ~ \
-            -t d \
-            -d 5 \
-            -u -E '.[a-fh-zA-FG-Z]*' \
-            --prune \\.git$ \
-            -x echo {//} \
-    | fzf)
+
+(sleep 3; exit 1) &
+
+PROJECT=$(fd \
+    --base-directory ~ \
+    -t d \
+    -d 5 \
+    -u -E '.[a-fh-zA-FG-Z]*' \
+    --prune \\.git$ \
+    -x echo {//} \
+    | fzf);
+if [ -n $PROJECT ] && [ ! "$PROJECT" = '' ]; then 
+    PROJECT=$(realpath $PROJECT)
+    NAME=$(basename $PROJECT)
+    if [ "$PROJECT" = "$HOME" ]; then
+        NAME="dotfiles"
+    fi
+    tmux select-window -t $NAME || \
+        tmux new-window -c "$PROJECT" -n "$NAME" /bin/zsh ~/.scripts/nvim_launch.zsh $PROJECT
+else
+    exit 1
+fi;