---

# Sources:
#   - https://github.com/tmux/tmux/wiki/

- name: Install and configure Tmux
  hosts: all
  tasks:

    - name: Install Tmux's package
      ansible.builtin.package:
        name: tmux

    - name: Write Tmux's configuration file
      ansible.builtin.copy:
        dest: "{{ ansible_user_dir }}/.tmux.conf"
        mode: u=rw,go=r
        content: |
          ################################################################################
          ## ~/.tmux.conf
          ################################################################################

          ###
          # Tmux behavior
          #################

          set -g xterm-keys on

          # scrollback size
          set -g history-limit 100000

          # enable mouse control (clickable windows, panes, resizable panes)
          set -g mouse on


          ###
          # Tmux visuals
          #################

          set -g default-terminal "screen-256color"
          set -g status-right '#H %Y-%m-%d %H:%M'


          ###
          # Window visuals
          ##################

          # renumber windows when one is closed
          set -g renumber-windows on

          # set the terminals' title
          set -g set-titles on

          # rename a window to the current program
          set-window-option -g automatic-rename on


          ###
          # Activity monitor
          ####################

          # highlight the active window
          # set-window-option -g window-status-current-style 'bg=red dim'

          # highlight a window's tab when it has activity
          set -g monitor-activity on

          # notify of a window's activity in the status bar
          set -g visual-activity on
        backup: true
