summaryrefslogtreecommitdiff
path: root/.local/bin
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@simplelittledream.com>2022-10-26 15:14:32 -0400
committerJacob McDonnell <jacob@simplelittledream.com>2022-10-26 15:14:32 -0400
commite92e82df51537e958a7d642bcd7898b1b5009327 (patch)
tree4fa9532f2e8fda1b49798d7a3d5bfe8219f0dca4 /.local/bin
parent6b6e91707ecf621a0bedad154351db8f1ccc2123 (diff)
Integrated ThePrimeagen's Tmux Environment
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/tmux-sessionizer29
1 files changed, 29 insertions, 0 deletions
diff --git a/.local/bin/tmux-sessionizer b/.local/bin/tmux-sessionizer
new file mode 100755
index 0000000..3780e18
--- /dev/null
+++ b/.local/bin/tmux-sessionizer
@@ -0,0 +1,29 @@
+#!/bin/zsh
+
+# This script is stolen from The Primeagen
+# https://github.com/ThePrimeagen/.dotfiles/
+
+if [[ $# -eq 1 ]]; then
+ selected=$1
+else
+ selected=$(find ~/Documents/Projects ~ ~/.config ~/Documents/Projects/git ~/Documents/Projects/Experiments -mindepth 1 -maxdepth 1 -type d | fzf)
+fi
+
+if [[ -z $selected ]]; then
+ exit 0
+fi
+
+selected_name=$(basename "$selected" | tr . _)
+tmux_running=$(pgrep tmux)
+
+if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
+ tmux new-session -s $selected_name -c $selected
+ exit 0
+fi
+
+if ! tmux has-session -t=$selected_name 2> /dev/null; then
+ tmux new-session -ds $selected_name -c $selected
+fi
+
+tmux switch-client -t $selected_name
+