diff --git a/home-devices.yml b/home-devices.yml index 5940c53..69b0a38 100644 --- a/home-devices.yml +++ b/home-devices.yml @@ -35,5 +35,8 @@ - name: Install docker ansible.builtin.import_playbook: src/docker.yml +- name: Manage Shell + ansible.builtin.import_playbook: src/shell.yml + - name: Run sudo without password ansible.builtin.import_playbook: src/sudonopass.yml diff --git a/src/shell.yml b/src/shell.yml new file mode 100644 index 0000000..f25a8bb --- /dev/null +++ b/src/shell.yml @@ -0,0 +1,41 @@ +--- +- name: Maintain Shell configuration + hosts: linux + become: true + become_user: sunrui + vars: + user: "sunrui" + + tasks: + - name: Zsh + apt: + name: zsh + state: present + - name: Set zsh as default shell + become: true + user: + name: "{{ user }}" + shell: /usr/bin/zsh + - name: Install oh-my-zsh + become: true + git: + repo: https://github.com/ohmyzsh/ohmyzsh.git + dest: /home/{{ user }}/.oh-my-zsh + clone: true + force: true + - name: Install zsh-autosuggestions plugin + become: true + git: + repo: https://github.com/zsh-users/zsh-autosuggestions.git + dest: /home/{{ user }}/.oh-my-zsh/custom/plugins/zsh-autosuggestions + clone: true + force: true + register: autosuggestions + + - name: Configure zsh-autosuggestions plugin + become: true + lineinfile: + path: /home/{{ user }}/.zshrc + regexp: '^plugins=' + line: 'plugins=(git zsh-autosuggestions)' + when: autosuggestions.changed