I have a better version (in the sense that it automatically names sessions after the current directory):
if [ -z "$1" ]; then
name="$(basename $PWD)"
name="${name//\./-}"
else
name=$1
fi
tmux has -t "=$name" && tmux attach -t "$name" && exit
tmux new-session -d -s "$name" -n shell
Re:lsix: Like "ls", but for images
by michaelmior on Friday June 07, 2024 @09:59AM
(#40608782)
Better is subjective. This version has no way to easily list sessions. Depends on what you want :)
The function below will also automatically detach other clients, but for me it's what I want since other clients are always just me on another machine, often with a different screen size.