summaryrefslogtreecommitdiff
path: root/tasks/zsh.yml
blob: 5301496d36c48c493eabd264eab8aa5341d8570c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
- name: Change default shell
  become: true
  ansible.builtin.shell: "usermod -s $(which zsh) {{ ansible_user_id }}"
  changed_when: true
  tags:
    - zsh

- name: Create .zshenv
  ansible.builtin.shell: "echo \"ZDOTDIR=~/.config/zsh\" > ~/.zshenv"
  changed_when: true
  tags:
    - zsh

- name: Install Oh My Zsh
  ansible.builtin.shell: zsh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  changed_when: true
  tags:
    - zsh

- name: Install zsh-autosuggestions plugin
  ansible.builtin.git:
    repo: 'https://github.com/zsh-users/zsh-autosuggestions.git'
    dest: "~/.config/zsh/ohmyzsh/plugins/zsh-autosuggestions"
    version: master
  tags:
    - zsh

- name: Install zsh-syntax-highlighting plugin
  ansible.builtin.git:
    repo: 'https://github.com/zsh-users/zsh-syntax-highlighting.git'
    dest: "~/.config/zsh/ohmyzsh/plugins/zsh-syntax-highlighting"
    version: master
  tags:
    - zsh

- name: Enable ZSH plugins
  ansible.builtin.lineinfile:
    path: "~/.config/zsh/.zshrc"
    regexp: '^plugins='
    line: plugins=(git tmux zsh-autosuggestions zsh-syntax-highlighting)
  tags:
    - zsh

- name: Enable tmux autostart
  ansible.builtin.lineinfile:
    path: "~/.config/zsh/.zshrc"
    line: |
      if [[ -z $TMUX ]]; then
        tmux -u attach || exec tmux -u new-session && exit
      fi
  tags:
    - zsh