# Managed by Ansible (mortis.kamino.system_baseline, tasks/tmux.yml). Do not edit: the next run overwrites it. # Interactive login shells with a terminal and an SSH connection only: scp, sftp, `ssh host command` and Ansible have no terminal # or no interactive shell, and `ssh -t host 'bash -lc cmd'` is a login shell that is not interactive (the case below keeps it out). # Off for one user: touch ~/.no-tmux case $- in *i*) if [ -n "$SSH_CONNECTION" ] && [ -z "$TMUX" ] && [ -t 0 ] && [ ! -e "$HOME/.no-tmux" ] && command -v tmux >/dev/null 2>&1; then # new-session -d fails when the session exists, so the windows below are made only when this login creates it (once, even # for two logins at the same moment). Windows close when their command exits; window 0 is always a plain shell. if tmux new-session -d -s {{ system_baseline_tmux_session | quote }} 2>/dev/null; then : {% for window in system_baseline_tmux_windows %} tmux new-window -d -t {{ ('=' ~ system_baseline_tmux_session ~ ':') | quote }} -n {{ window.name | quote }} {{ window.command | quote }} {% endfor %} fi # Not exec: a failed attach (for example a client TERM this host has no terminfo for) must leave a usable shell instead of # closing the connection on every login. A clean detach exits, so detaching ends the SSH connection. tmux attach-session -t {{ ('=' ~ system_baseline_tmux_session) | quote }} && exit echo 'tmux-autostart: could not attach to tmux, continuing with a plain shell (touch ~/.no-tmux to stop trying)' >&2 fi ;; esac