X-Git-Url: https://git.madduck.net/etc/tmux.git/blobdiff_plain/9979e20072b4abe8adaa4e269f011d5cce5f6297..941f9fb60367daa10020590112a49a6bc93c7be5:/.bin/tmux diff --git a/.bin/tmux b/.bin/tmux index 30d3017..38243a3 100755 --- a/.bin/tmux +++ b/.bin/tmux @@ -34,15 +34,26 @@ if [ "${1:-}" = last ]; then echo >&2 W: No tmux session ID stored, generating a new one… fi -elif [ -n "${1:-}" ]; then - real_tmux "$@" +else + case "${1:-;}" in + (\;) :;; + (*) real_tmux "$@";; + esac fi # only without argument create a new session with a random name/id to which we # can then attach -if ! command -v uuidgen >/dev/null; then +hascmd() { command -v "$@" >/dev/null;} + +if hascmd uuid; then alias uuidgen=uuid +elif hascmd uuidgen; then : +elif hascmd python3; then uuidgen() { python3 -c 'import uuid; print(uuid.uuid1())'; } +elif hascmd python; then + uuidgen() { python -c 'import uuid; print(uuid.uuid1())'; } +else + uuidgen() { dd if=/dev/urandom bs=16 count=1 status=none | base64; } fi UUID=$(uuidgen) echo "$UUID" > $LASTSESSIONIDFILE