Tmux smart
This commit is contained in:
parent
22d9f7409d
commit
771d23fe76
26
t
Executable file
26
t
Executable 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
|
Loading…
Reference in New Issue
Block a user