Files
ansible-role-oh-my-zsh/tasks/p10k-install.yml

75 lines
2.4 KiB
YAML

---
# Install powerlevel10k
- name: Ensure dependencies are installed.
ansible.builtin.package:
name: "{{ p10k_dependencies }}"
state: present
become: true
when: p10k_dependencies
- name: Get ZSH version
ansible.builtin.shell: "set -o pipefail; zsh --version | cut -d ' ' -f2 | cut -c1-3"
args:
executable: /bin/bash
check_mode: no
changed_when: false
register: zsh_version
- name: Powerlevel10k works only with ZSH >= 5.1
ansible.builtin.fail:
msg: "You are using ZSH version {{ zsh_version.stdout }}. The minimum required version for Powerlevel10k is 5.1"
when: zsh_version.stdout|float < 5.1
- name: Install powerlevel10k.
ansible.builtin.git:
repo: "{{ p10k_repository_url }}"
dest: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
depth: '1'
update: no
version: 'master'
with_items: "{{ paths.results }}"
- name: Setup powerlevel10k file permissions
ansible.builtin.file:
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
owner: "{{ item.item }}"
group: "{{ item.item }}"
recurse: yes
with_items: "{{ paths.results }}"
- name: Add powerlevel10k to zsh plugin
ansible.builtin.lineinfile:
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
regexp: ".*powerlevel10k.*"
line: "source ~/{{ p10k_path }}/powerlevel10k.zsh-theme"
owner: "{{ item.item }}"
group: "{{ item.item }}"
mode: '0644'
create: yes
with_items: "{{ paths.results }}"
- name: Enable powerlevel10 instant prompt
ansible.builtin.blockinfile:
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
owner: "{{ item.item }}"
group: "{{ item.item }}"
block: |
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
insertbefore: BOF
marker_begin: "BEGIN P10K INSTANT PROMPT"
marker_end: "END P10K INSTANT PROMPT"
with_items: "{{ paths.results }}"
- name: Enable powerlevel10k config file
ansible.builtin.blockinfile:
path: "{{ item.ansible_facts.user_home }}/{{ p10k_path }}"
owner: "{{ item.item }}"
group: "{{ item.item }}"
block: |
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
insertafter: EOF
marker_begin: "BEGIN P10K CONFIG FILE"
marker_end: "END P10K CONFIG FILE"
with_items: "{{ paths.results }}"