X-Git-Url: https://git.madduck.net/etc/tmux.git/blobdiff_plain/9ce693fdf7374a22dc6923018becc6c2c1c168f3..2c7d137a1d7e58bca2150d3e70b492f8c54c4ffb:/.bin/tmux?ds=sidebyside diff --git a/.bin/tmux b/.bin/tmux index 577b746..93837e0 100755 --- a/.bin/tmux +++ b/.bin/tmux @@ -13,7 +13,9 @@ real_tmux() { single_tmux_session() { local id; id="$1"; shift - real_tmux new -t "$id" "$@" + local flag; flag=t + real_tmux list-sessions | grep -q "^${id}:" || flag=s + real_tmux new -$flag "$id" "$@" } tmux_session_exists() { @@ -44,13 +46,13 @@ fi # only without argument create a new session with a random name/id to which we # can then attach -which() { command -v "$@" >/dev/null;} +hascmd() { command -v "$@" >/dev/null;} -if which uuid; then alias uuidgen=uuid -elif which uuidgen; then : -elif which python3; then +if hascmd uuid; then alias uuidgen=uuid +elif hascmd uuidgen; then : +elif hascmd python3; then uuidgen() { python3 -c 'import uuid; print(uuid.uuid1())'; } -elif which python; then +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; }