-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzsh.yml
More file actions
67 lines (59 loc) · 2.08 KB
/
zsh.yml
File metadata and controls
67 lines (59 loc) · 2.08 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
- hosts: localhost
name: Zsh
vars:
zsh_path: ~/.oh-my-zsh
zsh_autosuggestions_path: "{{ lookup('env', 'ZSH_CUSTOM') | default('~/.oh-my-zsh/custom', true) }}/plugins/zsh-autosuggestions"
tasks:
# TODO: Install zsh only if it is not already installed
- name: Install zsh
community.general.homebrew:
name:
- zsh
state: present
tags:
- zsh
# Change shell to zsh only if zsh is not already the default shell
- name: Change shell to zsh
become: true
ansible.builtin.shell: chsh -s $(which zsh)
register: chsh_zsh
changed_when: chsh_zsh.rc == 0 # this is needed to avoid ansible-lint error when running shell commands
tags:
- zsh
- name: Check oh-my-zsh is already installed
ansible.builtin.stat:
path: "{{ zsh_path }}"
get_checksum: false
register: omz_dir
- name: Install oh-my-zsh
ansible.builtin.shell: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
register: oh_my_zsh
changed_when: oh_my_zsh.rc == 0 # this is needed to avoid ansible-lint error when running shell commands
when: not omz_dir.stat.exists
tags:
- zsh
- name: Check zsh-autosuggestions is already installed
ansible.builtin.stat:
path: "{{ zsh_autosuggestions_path }}"
get_checksum: false
register: omz_autosuggest_dir
- name: Install zsh-autosuggestions
ansible.builtin.git: # noqa: latest
repo: "https://github.com/zsh-users/zsh-autosuggestions.git"
dest: "{{ zsh_autosuggestions_path }}"
when: not omz_autosuggest_dir.stat.exists
tags:
- zsh
- name: Remove default .zshrc
ansible.builtin.command: mv $HOME/.zshrc $HOME/.zshrc.org
args:
removes: $HOME/.zshrc
creates: $HOME/.zshrc.org
tags:
- zsh
- name: Move .zshrc.pre-oh-my-zsh to .zshrc
ansible.builtin.command: mv $HOME/.zshrc.pre-oh-my-zsh $HOME/.zshrc
args:
removes: $HOME/.zshrc.pre-oh-my-zsh
tags:
- zsh