#!/bin/sh if [ "$#" -eq 0 ]; then set -- "$( find ~/.local/src/* -prune ! -path "$(pwd)" -printf "%T+\t%p\n" | sort | cut -f2 | fzf --tmux --tac --exit-0 -d/ --with-nth=-1 --preview='lesspipe.sh {}' )" test -n "$1" || exit 0 fi if [ ! -d "$1" ]; then exit 1 fi if ! session="$(tmux ls -f "#{==:#{session_path},$1}" -F '#S' 2>/dev/null | grep ^)"; then session="$(tmux new -dc "$1" -PF'#S')" fi if [ -z "$TMUX" ]; then tmux attach-session -t "$session" else tmux switch-client -t "$session" fi