X-Git-Url: https://git.madduck.net/etc/tmux.git/blobdiff_plain/455487e9e45cf78f4fea7fb91dab927b95e42bf4..9ce693fdf7374a22dc6923018becc6c2c1c168f3:/.bin/tmux diff --git a/.bin/tmux b/.bin/tmux index d6ff4b2..577b746 100755 --- a/.bin/tmux +++ b/.bin/tmux @@ -20,7 +20,7 @@ tmux_session_exists() { _tmux_eval_only=1 real_tmux has-session -t "$1" } -if [ "${1:-}" = --connect-to-last ]; then +if [ "${1:-}" = last ]; then shift if [ -f "$LASTSESSIONIDFILE" ]; then UUID="$(cat $LASTSESSIONIDFILE)" @@ -34,13 +34,27 @@ if [ "${1:-}" = --connect-to-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 +which() { command -v "$@" >/dev/null;} + +if which uuid; then alias uuidgen=uuid +elif which uuidgen; then : +elif which python3; then + uuidgen() { python3 -c 'import uuid; print(uuid.uuid1())'; } +elif which 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