27 lines
590 B
Bash
Executable File
27 lines
590 B
Bash
Executable File
#!/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
|