From 9ce693fdf7374a22dc6923018becc6c2c1c168f3 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sat, 28 Mar 2020 08:05:19 +1300 Subject: [PATCH] uuidgen alternatives --- .bin/tmux | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.bin/tmux b/.bin/tmux index 6a4a360..577b746 100755 --- a/.bin/tmux +++ b/.bin/tmux @@ -44,8 +44,16 @@ 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 +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 -- 2.39.2