#!/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