Tmux smart

This commit is contained in:
CronyAkatsuki 2023-11-10 21:41:43 +01:00
parent 22d9f7409d
commit 771d23fe76

26
t Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
[ "$1" ] && result=$(zoxide query $1) || result=$(zoxide query -l | fzf --prompt "Choose directory: ")
[ -z "$result" ] && exit 0
name=$(basename $result)
session=$(tmux list-sessions | grep $name | awk '{print $1}' | sed 's/.$//')
if [ -z "$TMUX" ]; then
if [ -z "$session" ]; then
cd $result
tmux new-session -s $name
else
tmux attach -t $session
fi
else
if [ -z "$session" ]; then
cd $result
tmux new-session -d -s $name
tmux switch-client -t $name
else
tmux switch-client -t $session
fi
fi