You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
649 B

#!/usr/bin/env sh
WORKSPACES=${WORKSPACES:-$HOME/Documents}
IFS=':' findargs=$WORKSPACES
if test -z "$1"; then
sessiondir="$(find $findargs -maxdepth 2 -type d 2>/dev/null | fzf)"
else
sessiondir="$1"
fi
if test -z "$sessiondir" || ! test -d "$sessiondir"; then
echo "$sessiondir is not a directory. Aborting..."
exit 0
fi
name="$(basename "$(realpath "$sessiondir" )" | tr '.' '_')"
if test -z "$TMUX" && test -z "$(pgrep tmux)"; then
tmux new-session -c "$sessiondir" -s "$name"
else
if ! tmux has-session -t="$name" 2> /dev/null; then
tmux new-session -d -c "$sessiondir" -s "$name"
fi
tmux switch-client -t "$name"
fi