- name: symlink ~/.zprezto
  file:
    src: "{{ ansible_env.HOME }}/.dotfiles/src/prezto"
    dest: "{{ ansible_env.HOME}}/.zprezto"
    state: link

- name: get Prezto runcoms from dotfiles
  shell: ls ~/.zprezto/runcoms | grep -v README.md
  register: prezto_runcoms

- name: symlink Prezto runcoms
  file:
    src: "{{ ansible_env.HOME }}/.zprezto/runcoms/{{ item }}"
    dest: "{{ ansible_env.HOME}}/.{{ item }}"
    state: link
  with_items: "{{ prezto_runcoms.stdout_lines }}"

- name: find where zsh is
  command: which zsh
  register: which_zsh

- name: add zsh to /etc/shells
  lineinfile: dest=/etc/shells line={{ which_zsh.stdout | trim }} state=present
  become: yes

- name: set the default user shell to zsh
  user: name={{ ansible_env.USER }} shell={{ which_zsh.stdout | trim }}
  become: yes