---
- block:
    - name: fish | Create necessary directories
      file:
        path: '~/.config/fish/{{ item }}'
        state: directory
        mode: 0755
      loop:
        - completions
        - conf.d
        - functions

    - name: fish | Copy function files
      copy:
        src: '{{ item }}'
        dest: ~/.config/fish/functions/
        mode: 0644
      loop:
        - fish_greeting.fish
        - fish_user_key_bindings.fish

    - name: fish | Copy config templates
      template:
        src: '{{ item }}.j2'
        dest: '~/.config/fish/conf.d/{{ item }}.fish'
        force: yes
        mode: 0644
      loop:
        - aliases
        - colors
        - env

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

    - name: fish | Download fzf_key_bindings.fish
      get_url:
        url: https://github.com/junegunn/fzf/raw/master/shell/key-bindings.fish
        dest: ~/.config/fish/functions/fzf_key_bindings.fish
        mode: 0644

    - name: fish | Install fisher
      shell: curl -sSL https://git.io/fisher | source && fisher install jorgebucaran/fisher
      args:
        executable: /usr/bin/fish
        creates: ~/.config/fish/functions/fisher.fish

    - name: fish | Install replay.fish
      command: fish -c 'fisher install jorgebucaran/replay.fish'
      args:
        creates: ~/.config/fish/functions/replay.fish

    - name: fish | Install autopair.fish
      command: fish -c 'fisher install jorgebucaran/autopair.fish'
      args:
        creates: ~/.config/fish/conf.d/autopair.fish

    - name: fish | Install forgit
      command: fish -c 'fisher install wfxr/forgit'
      args:
        creates: ~/.config/fish/conf.d/forgit.plugin.fish
  tags: fish

- name: bash | Copy .bashrc
  tags: bash
  copy:
    src: bashrc
    dest: ~/.bashrc
    force: yes
    mode: 0644

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

    - name: xonsh | Copy config
      copy:
        src: rc.xsh
        dest: ~/.config/xonsh/rc.xsh
        force: yes
        mode: 0644
  tags: [ never, xonsh ]

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

    - name: nushell | Copy config
      copy:
        src: config.toml
        dest: ~/.config/nu/config.toml
        force: yes
        mode: 0644
  tags: nushell

- name: starship | Copy config
  tags: starship
  copy:
    src: starship.toml
    dest: ~/.config/starship.toml
    force: yes
    mode: 0644
