---
- block:
    - name: tmux | Create config directory
      file:
        path: ~/.config/tmux
        state: directory
        mode: 0755

    - name: tmux | Copy config
      template:
        src: tmux.j2
        dest: ~/.config/tmux/tmux.conf
        force: yes
        mode: 0644

    - name: tmux | Install tpm
      git:
        depth: 1
        repo: https://github.com/tmux-plugins/tpm.git
        dest: ~/.config/tmux/plugins/tpm
  when: multiplexer == 'tmux'

- block:
    - name: zellij | Create config directory
      file:
        path: ~/.config/zellij
        state: directory
        mode: 0755

    - name: zellij | Copy config
      template:
        src: config.j2
        dest: ~/.config/zellij/config.yaml
        force: yes
        mode: 0644

    - name: zellij | Check whether zellij is installed
      command: which zellij
      register: zellij_check
      failed_when: no
      changed_when: no

    - name: zellij | Generate zellij fish completion file
      shell:
        cmd: zellij setup --generate-completion fish > ~/.config/fish/completions/zellij.fish
        creates: ~/.config/fish/completions/zellij.fish
      when: zellij_check.rc == 0
  when: multiplexer == 'zellij'
