In retrospect, command -v seems to be more portable than which[1]. So a better version would be:
if command -v tmux >/dev/null 2>&1; then # if not inside a tmux session, and if no session is started, start # a new session test -z "$TMUX" && (tmux attach || tmux new-session) fi Though I suppose this is likely academic in nature. [1]: https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then -- https://amissing.link

