Every time I open a terminal on macOS, zsh takes like a second to show the
prompt. It’s super annoying!
I profiled using
1
2
3
4
5
6
7
8
9
10
|
if [ -n "${ZSH_DEBUGRC+1}" ]; then
zmodload zsh/zprof
fi
# your zsh config
if [ -n "${ZSH_DEBUGRC+1}" ]; then
zprof
fi
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
| $ time ZSH_DEBUGRC=1 zsh -i -c exit
num calls time self name
--------------------------------------------------------------------------------
---
1) 1 36.73 36.73 26.10% 36.73 36.73 26.10% autoenv_i
nit
2) 1 22.16 22.16 15.75% 22.16 22.16 15.75% _mise_hoo
k
3) 21 28.72 1.37 20.41% 18.10 0.86 12.86% _omz_sour
ce
4) 2 15.97 7.99 11.35% 15.97 7.99 11.35% compaudit
5) 1 13.75 13.75 9.77% 13.75 13.75 9.77% (anon) [/
Users/mgreco/.oh-my-zsh/tools/check_for_upgrade.sh:157]
6) 1 24.00 24.00 17.05% 10.24 10.24 7.28% handle_up
date
7) 1 8.93 8.93 6.34% 8.93 8.93 6.34% zrecompil
e
8) 1 8.81 8.81 6.26% 8.81 8.81 6.26% test-ls-a
rgs
9) 1 19.41 19.41 13.79% 3.44 3.44 2.44% compinit
10) 1 0.61 0.61 0.43% 0.61 0.61 0.43% regexp-re
place
11) 1 0.57 0.57 0.41% 0.57 0.57 0.41% colors
12) 6 0.44 0.07 0.31% 0.44 0.07 0.31% add-zsh-h
ook
13) 4 0.23 0.06 0.16% 0.23 0.06 0.16% compdef
14) 2 0.22 0.11 0.16% 0.22 0.11 0.16% is-at-lea
st
15) 8 0.14 0.02 0.10% 0.14 0.02 0.10% addToPath
Front
16) 8 0.13 0.02 0.10% 0.13 0.02 0.10% addToPath
17) 1 36.85 36.85 26.18% 0.12 0.12 0.08% autoenv_c
d
18) 4 0.07 0.02 0.05% 0.07 0.02 0.05% addToMyGi
tProjects
19) 3 0.03 0.01 0.02% 0.03 0.01 0.02% is_theme
20) 2 0.01 0.01 0.01% 0.01 0.01 0.01% env_defau
lt
21) 1 36.86 36.86 26.20% 0.01 0.01 0.01% enable_au
toenv
22) 1 0.01 0.01 0.01% 0.01 0.01 0.01% bashcompi
nit
23) 1 36.85 36.85 26.19% 0.01 0.01 0.00% cd
--------------------------------------------------------------------------------
---
21) 1 36.86 36.86 26.20% 0.01 0.01 0.01% enable_au
toenv
1/1 36.85 36.85 26.19% 0.01 0.01 cd [23]
--------------------------------------------------------------------------------
---
1/1 36.85 36.85 26.19% 0.01 0.01 enable_
autoenv [21]
23) 1 36.85 36.85 26.19% 0.01 0.01 0.00% cd
1/1 36.85 36.85 26.18% 0.12 0.12 autoenv
_cd [17]
--------------------------------------------------------------------------------
---
1/1 36.85 36.85 26.18% 0.12 0.12 cd [23]
17) 1 36.85 36.85 26.18% 0.12 0.12 0.08% autoenv_c
d
1/1 36.73 36.73 26.10% 36.73 36.73 autoenv
_init [1]
--------------------------------------------------------------------------------
---
1/1 36.73 36.73 26.10% 36.73 36.73 autoenv
_cd [17]
1) 1 36.73 36.73 26.10% 36.73 36.73 26.10% autoenv_i
nit
--------------------------------------------------------------------------------
---
3) 21 28.72 1.37 20.41% 18.10 0.86 12.86% _omz_sour
ce
1/1 0.01 0.01 0.01% 0.01 0.01 bashcom
pinit [22]
2/2 0.01 0.01 0.01% 0.01 0.01 env_def
ault [20]
2/4 0.09 0.04 0.06% 0.09 0.04 compdef
[13]
2/2 0.22 0.11 0.16% 0.22 0.11 is-at-l
east [14]
4/6 0.31 0.08 0.22% 0.31 0.08 add-zsh
-hook [12]
1/1 0.57 0.57 0.41% 0.57 0.57 colors
[11]
1/1 0.61 0.61 0.43% 0.61 0.61 regexp-
replace [10]
1/1 8.81 8.81 6.26% 8.81 8.81 test-ls
-args [8]
--------------------------------------------------------------------------------
---
6) 1 24.00 24.00 17.05% 10.24 10.24 7.28% handle_up
date
1/1 13.75 13.75 9.77% 13.75 13.75 (anon)
[/Users/mgreco/.oh-my-zsh/tools/check_for_upgrade.sh:157] [5]
--------------------------------------------------------------------------------
---
2) 1 22.16 22.16 15.75% 22.16 22.16 15.75% _mise_hoo
k
--------------------------------------------------------------------------------
---
9) 1 19.41 19.41 13.79% 3.44 3.44 2.44% compinit
1/2 15.97 15.97 11.35% 0.18 0.18 compaud
it [4]
--------------------------------------------------------------------------------
---
1/2 15.97 15.97 11.35% 0.18 0.18 compini
t [9]
1/2 15.79 15.79 11.22% 15.79 15.79 compaud
it [4]
4) 2 15.97 7.99 11.35% 15.97 7.99 11.35% compaudit
1/2 15.79 15.79 11.22% 15.79 15.79 compaud
it [4]
--------------------------------------------------------------------------------
---
1/1 13.75 13.75 9.77% 13.75 13.75 handle_
update [6]
5) 1 13.75 13.75 9.77% 13.75 13.75 9.77% (anon) [/
Users/mgreco/.oh-my-zsh/tools/check_for_upgrade.sh:157]
--------------------------------------------------------------------------------
---
7) 1 8.93 8.93 6.34% 8.93 8.93 6.34% zrecompil
e
--------------------------------------------------------------------------------
---
1/1 8.81 8.81 6.26% 8.81 8.81 _omz_so
urce [3]
8) 1 8.81 8.81 6.26% 8.81 8.81 6.26% test-ls-a
rgs
--------------------------------------------------------------------------------
---
1/1 0.61 0.61 0.43% 0.61 0.61 _omz_so
urce [3]
10) 1 0.61 0.61 0.43% 0.61 0.61 0.43% regexp-re
place
--------------------------------------------------------------------------------
---
1/1 0.57 0.57 0.41% 0.57 0.57 _omz_so
urce [3]
11) 1 0.57 0.57 0.41% 0.57 0.57 0.41% colors
--------------------------------------------------------------------------------
---
4/6 0.31 0.08 0.22% 0.31 0.08 _omz_so
urce [3]
12) 6 0.44 0.07 0.31% 0.44 0.07 0.31% add-zsh-h
ook
--------------------------------------------------------------------------------
---
2/4 0.09 0.04 0.06% 0.09 0.04 _omz_so
urce [3]
13) 4 0.23 0.06 0.16% 0.23 0.06 0.16% compdef
--------------------------------------------------------------------------------
---
2/2 0.22 0.11 0.16% 0.22 0.11 _omz_so
urce [3]
14) 2 0.22 0.11 0.16% 0.22 0.11 0.16% is-at-lea
st
--------------------------------------------------------------------------------
---
15) 8 0.14 0.02 0.10% 0.14 0.02 0.10% addToPath
Front
--------------------------------------------------------------------------------
---
18) 4 0.07 0.02 0.05% 0.07 0.02 0.05% addToMyGitProjects
-----------------------------------------------------------------------------------
19) 3 0.03 0.01 0.02% 0.03 0.01 0.02% is_theme
-----------------------------------------------------------------------------------
2/2 0.01 0.01 0.01% 0.01 0.01 _omz_source [3]
20) 2 0.01 0.01 0.01% 0.01 0.01 0.01% env_default
-----------------------------------------------------------------------------------
1/1 0.01 0.01 0.01% 0.01 0.01 _omz_source [3]
22) 1 0.01 0.01 0.01% 0.01 0.01 0.01% bashcompinit
ZSH_DEBUGRC=1 zsh -i -c exit 0.16s user 0.18s system 38% cpu 0.873 total
|
So, I’ve just disabled:
oh-my-zsh
completions
starship
and look at this now:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| $ time ZSH_DEBUGRC=1 zsh -i -c exit
num calls time self name
-----------------------------------------------------------------------------------
1) 1 46.78 46.78 69.34% 46.78 46.78 69.34% autoenv_init
2) 1 20.14 20.14 29.85% 20.14 20.14 29.85% _mise_hook
3) 1 47.00 47.00 69.66% 0.22 0.22 0.32% autoenv_cd
4) 8 0.12 0.02 0.19% 0.12 0.02 0.19% addToPathFront
5) 8 0.12 0.02 0.18% 0.12 0.02 0.18% addToPath
6) 4 0.05 0.01 0.07% 0.05 0.01 0.07% addToMyGitProjects
7) 1 47.03 47.03 69.71% 0.02 0.02 0.04% enable_autoenv
8) 1 47.01 47.01 69.68% 0.01 0.01 0.01% cd
-----------------------------------------------------------------------------------
7) 1 47.03 47.03 69.71% 0.02 0.02 0.04% enable_autoenv
1/1 47.01 47.01 69.68% 0.01 0.01 cd [8]
-----------------------------------------------------------------------------------
1/1 47.01 47.01 69.68% 0.01 0.01 enable_autoenv [7]
8) 1 47.01 47.01 69.68% 0.01 0.01 0.01% cd
1/1 47.00 47.00 69.66% 0.22 0.22 autoenv_cd [3]
-----------------------------------------------------------------------------------
1/1 47.00 47.00 69.66% 0.22 0.22 cd [8]
3) 1 47.00 47.00 69.66% 0.22 0.22 0.32% autoenv_cd
1/1 46.78 46.78 69.34% 46.78 46.78 autoenv_init [1]
-----------------------------------------------------------------------------------
1/1 46.78 46.78 69.34% 46.78 46.78 autoenv_cd [3]
1) 1 46.78 46.78 69.34% 46.78 46.78 69.34% autoenv_init
-----------------------------------------------------------------------------------
2) 1 20.14 20.14 29.85% 20.14 20.14 29.85% _mise_hook
-----------------------------------------------------------------------------------
4) 8 0.12 0.02 0.19% 0.12 0.02 0.19% addToPathFront
-----------------------------------------------------------------------------------
5) 8 0.12 0.02 0.18% 0.12 0.02 0.18% addToPath
-----------------------------------------------------------------------------------
6) 4 0.05 0.01 0.07% 0.05 0.01 0.07% addToMyGitProjects
ZSH_DEBUGRC=1 zsh -i -c exit 0.06s user 0.09s system 30% cpu 0.462 total
|
I have a terribly boring and plain terminal, but at least it’s very fast.
BTW, I’ve never had this issue on Linux.
I Hate you MacOS (written on MacOS)