Skip to content

Custom dependencies

Patrick edited this page May 9, 2024 · 1 revision

Distribute a custom .zshrc file with a dependency.

  • Install the zsh package.
  • Set zsh as default shell for the specified users.
  • Distribute a custom .zshrc for each user.
  • Install a dependency.

main.yml file in your project folder:

- name: zsh
  hosts: all
  vars:
    zsh_config_backup: false
    zsh_config_overwrite: true

    zsh_users:
      - lorem
      - ipsum

    zsh_users_config:
      - template: "zshrc.j2"
        filename: ".zshrc"

    zsh_dependencies:
      - exa
  roles:
    - bec.shell.zsh
  tasks:
    - ansible.builtin.debug:
        msg: "ZSH has been installed and exa is used to list files."

zshrc.j2 file in your templates folder:

{% if zsh_config_overwrite is true %}
#
# {{ ansible_managed }}
#
{% endif %}

alias ls='exa --group-directories-first'
alias ll='exa --group-directories-first -a -l -b -g -F -G'
alias lx='exa --group-directories-first -a -l -b -g -h -H -i -m -S --time-style=long-iso'

exa is an improved file lister with more features and better defaults. It uses colours to distinguish file types and metadata.

Clone this wiki locally