All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
4 LASTSESSIONIDFILE="${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/tmux-last-session-id"
8 if [ -n "${_tmux_eval_only:-}" ]; then
11 $exec $(which -a tmux | grep -v $HOME | head -1) "$@"
14 single_tmux_session() {
15 local id; id="$1"; shift
16 real_tmux new -t "$id" "$@"
19 tmux_session_exists() {
20 _tmux_eval_only=1 real_tmux has-session -t "$1"
23 if [ "${1:-}" = last ]; then
25 if [ -f "$LASTSESSIONIDFILE" ]; then
26 UUID="$(cat $LASTSESSIONIDFILE)"
27 if tmux_session_exists $UUID; then
28 echo >&2 Attaching to existing session with ID $UUID…
29 single_tmux_session "$(cat $LASTSESSIONIDFILE)" "$@"
31 echo >&2 W: No tmux session with ID $UUID found, generating a new one…
34 echo >&2 W: No tmux session ID stored, generating a new one…
44 # only without argument create a new session with a random name/id to which we
47 hascmd() { command -v "$@" >/dev/null;}
49 if hascmd uuid; then alias uuidgen=uuid
50 elif hascmd uuidgen; then :
51 elif hascmd python3; then
52 uuidgen() { python3 -c 'import uuid; print(uuid.uuid1())'; }
53 elif hascmd python; then
54 uuidgen() { python -c 'import uuid; print(uuid.uuid1())'; }
56 uuidgen() { dd if=/dev/urandom bs=16 count=1 status=none | base64; }
59 echo "$UUID" > $LASTSESSIONIDFILE
61 echo >&2 Starting a new session with ID $UUID…
63 single_tmux_session $UUID "$@"