Skip to content

Commit

Permalink
shell: add ohmyposh
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Jul 17, 2024
1 parent 35478ff commit b53b7a5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
12 changes: 12 additions & 0 deletions roles/shell/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,15 @@ shell_zsh_zshrc_block_custom: ""
shell_zsh_plugins: "(git docker docker-compose ansible)"
shell_zsh_binary_previous_path: "/bin/zsh5"
shell_zsh_binary_path: "/bin/zsh"

################################
# Oh My Posh
################################

shell_ohmyposh_enabled: false
# Takes a file path or url to a config file
shell_ohmyposh_config: ""

shell_zsh_zshrc_oh_my_posh: |
# Oh My Posh
eval "$(oh-my-posh init zsh{{ ' --config ' + shell_ohmyposh_config if shell_ohmyposh_config | length > 0 else '' }})"
26 changes: 22 additions & 4 deletions roles/shell/tasks/subtasks/shell/zsh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,30 @@

- name: ZSH | Set ZSH as default shell
ansible.builtin.debug:
msg:
- "Set ZSH as default shell"
msg: "Set ZSH as default shell"
when: (shell_update_task is changed)

- name: "Oh My Posh Block"
when: shell_ohmyposh_enabled
block:
- name: "Install Oh My Posh"
ansible.builtin.shell: "curl -s https://ohmyposh.dev/install.sh | bash -s -- -d /usr/local/bin/"

- name: "Install Meslo Nerd Font"
ansible.builtin.shell: "oh-my-posh font install meslo"

- name: ZSH | Add Oh My Posh to '{{ shell_zsh_zshrc_path }}'
ansible.builtin.blockinfile:
path: "{{ shell_zsh_zshrc_path }}"
marker: "### SALTBOX MANAGED BLOCK 3 - {mark} ###"
block: "{{ shell_zsh_zshrc_oh_my_posh }}"
state: present
create: false
owner: "{{ user.name }}"
group: "{{ user.name }}"
mode: "0664"

- name: ZSH | Default shell set to ZSH
ansible.builtin.debug:
msg:
- "Changes will apply on session restart."
msg: "Changes will apply on session restart."
when: (shell_update_task is changed) and ('shell' in ansible_run_tags)

0 comments on commit b53b7a5

Please sign in to comment.