Skip to content

Commit 3d4c493

Browse files
committedSep 21, 2024
add zsh ansible test
1 parent b0c601f commit 3d4c493

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
 

‎ansible/playbooks/zsh.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
- name: Configure Zsh, Neofetch, FZF, and custom .zshrc
3+
hosts: all
4+
become: true
5+
vars:
6+
zsh_custom: "{{ ansible_env.HOME }}/.oh-my-zsh/custom"
7+
user: "{{ ansible_user }}"
8+
9+
tasks:
10+
11+
- name: Install necessary packages
12+
apt:
13+
name:
14+
- zsh
15+
- neofetch
16+
- fzf
17+
state: present
18+
update_cache: yes
19+
20+
- name: Change default shell to Zsh
21+
user:
22+
name: "{{ user }}"
23+
shell: /bin/zsh
24+
25+
- name: Install Oh My Zsh (unattended)
26+
shell: |
27+
RUNZSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
28+
args:
29+
chdir: "/home/{{ user }}"
30+
creates: "/home/{{ user }}/.oh-my-zsh"
31+
32+
- name: Clone zsh-syntax-highlighting plugin
33+
git:
34+
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
35+
dest: "{{ zsh_custom }}/plugins/zsh-syntax-highlighting"
36+
update: no
37+
38+
- name: Clone zsh-autosuggestions plugin
39+
git:
40+
repo: https://github.com/zsh-users/zsh-autosuggestions.git
41+
dest: "{{ zsh_custom }}/plugins/zsh-autosuggestions"
42+
update: no
43+
44+
- name: Clone zsh-history-substring-search plugin
45+
git:
46+
repo: https://github.com/zsh-users/zsh-history-substring-search.git
47+
dest: "{{ zsh_custom }}/plugins/zsh-history-substring-search"
48+
update: no
49+
50+
- name: Clone zsh-you-should-use plugin
51+
git:
52+
repo: https://github.com/MichaelAquilina/zsh-you-should-use.git
53+
dest: "{{ zsh_custom }}/plugins/you-should-use"
54+
update: no
55+
56+
- name: Ensure .local/bin directory exists
57+
file:
58+
path: "/home/{{ user }}/.local/bin"
59+
state: directory
60+
owner: "{{ user }}"
61+
mode: '0755'
62+
63+
- name: Download Oh My Posh binary
64+
get_url:
65+
url: https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64
66+
dest: "/home/{{ user }}/.local/bin/oh-my-posh"
67+
mode: '0755'
68+
69+
- name: Ensure ownership of .local/bin/oh-my-posh
70+
file:
71+
path: "/home/{{ user }}/.local/bin/oh-my-posh"
72+
owner: "{{ user }}"
73+
mode: '0755'
74+
75+
- name: Set up custom .zshrc
76+
copy:
77+
dest: "/home/{{ user }}/.zshrc"
78+
content: |
79+
# Path to your Oh My Zsh installation.
80+
export ZSH="$HOME/.oh-my-zsh"
81+
export PATH=$PATH:$HOME/.local/bin
82+
83+
# Set theme
84+
ZSH_THEME="robbyrussell"
85+
86+
# Plugins
87+
plugins=(git ubuntu copypath copyfile dirhistory zsh-interactive-cd docker docker-compose opentofu zsh-history-substring-search zsh-autosuggestions zsh-syntax-highlighting you-should-use)
88+
89+
source $ZSH/oh-my-zsh.sh
90+
91+
# Set up Oh My Posh
92+
eval "$(oh-my-posh init zsh --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/sonicboom_dark.omp.json)"
93+
94+
# Custom aliases
95+
alias dcd="docker compose down"
96+
alias dcu="docker compose up -d"
97+
98+
# Display system information
99+
neofetch
100+
owner: "{{ user }}"
101+
mode: '0644'

0 commit comments

Comments
 (0)
Please sign in to comment.