---
# file: roles/chruby/tasks/main.yml

- name: Install chruby
  homebrew:
    name: chruby
    state: present

- name: Source chruby.sh & auto.sh from {{ ansible_user_dir }}/.bashrc
  blockinfile:
    dest: "{{ ansible_user_dir }}/.bashrc"
    block: |
      [ -s /usr/local/opt/chruby/share/chruby/chruby.sh ] && . /usr/local/opt/chruby/share/chruby/chruby.sh
      [ -s /usr/local/opt/chruby/share/chruby/auto.sh ] && . /usr/local/opt/chruby/share/chruby/auto.sh
    marker: '# {mark} ANSIBLE MANAGED BLOCK - chruby'
    create: yes

---
# file: roles/chruby/tasks/main.yml

- name: Install chruby
  homebrew:
    name: chruby
    state: present

- name: Source chruby.sh & auto.sh from {{ ansible_user_dir }}/.bashrc
  blockinfile:
    dest: "{{ ansible_user_dir }}/.bashrc"
    block: |
      [ -s /usr/local/share/chruby/chruby.sh ] && . /usr/local/share/chruby/chruby.sh
      if [ -s /usr/local/share/chruby/auto.sh ]; then
        . /usr/local/share/chruby/auto.sh
        if [[ "$__bp_imported" == "defined" ]]; then
          if [[ ! "$preexec_functions" == *chruby_auto* ]]; then
            preexec_functions+=("chruby_auto")
          fi
        fi
      fi
    marker: '# {mark} ANSIBLE MANAGED BLOCK - chruby'
    create: yes

Make chruby_auto work with iterm2_shell_integration.bash
Make chruby_auto work with iterm2_shell_integration.bash
