diff --git a/t b/t new file mode 100755 index 0000000..3f28719 --- /dev/null +++ b/t @@ -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