fix(tmux): improve tmuxsess behaviour
This commit is contained in:
parent
431566d260
commit
b99a48d09a
|
@ -13,7 +13,22 @@ if [ -z "$1" ]; then
|
||||||
else
|
else
|
||||||
sessionname="$1"
|
sessionname="$1"
|
||||||
fi
|
fi
|
||||||
tmux new -d -s $sessionname
|
|
||||||
|
tmux_new_result=$(tmux new -d -s $sessionname 2>&1) || true
|
||||||
|
exitcode=$?
|
||||||
|
|
||||||
|
if echo "$tmux_new_result" | grep -q "duplicate session"; then
|
||||||
|
echo "Session $sessionname already exists. Attaching..."
|
||||||
|
tmux new -d -A -s $sessionname
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $exitcode -ne 0 ]; then
|
||||||
|
echo "$tmux_new_result"
|
||||||
|
exit $exitcode
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: fix sessionname containing full stop which are renamed by tmux
|
||||||
tmux rename-window -t $sessionname:1 cli
|
tmux rename-window -t $sessionname:1 cli
|
||||||
tmux new-window -t $sessionname -n vim zsh -ic nvim
|
tmux new-window -t $sessionname -n vim zsh -ic nvim
|
||||||
tmux select-window -t $sessionname:1
|
tmux select-window -t $sessionname:1
|
||||||
|
|
Loading…
Reference in New Issue