<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>oh my zsh on Kevin Heruer</title><link>/tags/oh-my-zsh/</link><description>Recent content in oh my zsh on Kevin Heruer</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 17 Dec 2020 09:16:54 +0100</lastBuildDate><atom:link href="/tags/oh-my-zsh/index.xml" rel="self" type="application/rss+xml"/><item><title>Zsh Speedup</title><link>/posts/2020/12/17/zsh-speedup/</link><pubDate>Thu, 17 Dec 2020 09:16:54 +0100</pubDate><guid>/posts/2020/12/17/zsh-speedup/</guid><description>I&amp;rsquo;ve been experiencing some slowdowns in my shell lately, I could not explain why. But I am using Oh My Zsh, and after some searching I found a blog post by Matthew J. Clemente that has a complete walkthrough of how to diagnose and fix slow (Oh My Zsh) shells.
You start by measuring actual load times to set a base with a simple function you can put into your .</description><content>&lt;p>I&amp;rsquo;ve been experiencing some slowdowns in my shell lately, I could not explain why.
But I am using &lt;a href="https://github.com/ohmyzsh/ohmyzsh">Oh My Zsh&lt;/a>, and after some
searching I found a blog post by Matthew J. Clemente that has a complete walkthrough
of how to diagnose and fix slow (Oh My Zsh) shells.&lt;/p>
&lt;p>You start by measuring actual load times to set a base with a simple function you can
put into your .zshrc file:
&lt;div class="collapsable-code">
&lt;input id="936752814" type="checkbox" />
&lt;label for="936752814">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
timezsh() {
shell=${1-$SHELL}
for i in $(seq 1 10); do /usr/bin/time $shell -i -c exit; done
}
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>Now you can run timezsh and see how long it takes for your shell to start up and be ready.
To figure out exactly which plugin is causing the slowdown you can run the following to
see how long it takes for each plugin to be loaded in:
&lt;div class="collapsable-code">
&lt;input id="372695814" type="checkbox" />
&lt;label for="372695814">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
timer=$(($(gdate &amp;#43;%s%N)/1000000))
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
fi
now=$(($(gdate &amp;#43;%s%N)/1000000))
elapsed=$(($now-$timer))
echo $elapsed&amp;#34;:&amp;#34; $plugin
done
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>In my case it was the kubectl plugin for Oh My Zsh, the fix was to use the given kubectl command
to load in the autocomplete:
&lt;div class="collapsable-code">
&lt;input id="762914385" type="checkbox" />
&lt;label for="762914385">
&lt;span class="collapsable-code__language">bash&lt;/span>
&lt;span class="collapsable-code__toggle" data-label-expand="△" data-label-collapse="▽">&lt;/span>
&lt;/label>
&lt;pre class="language-bash" >&lt;code>
function kubectl() {
if ! type __start_kubectl &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then
source &amp;lt;(command kubectl completion zsh)
fi
command kubectl &amp;#34;$@&amp;#34;
}
&lt;/code>&lt;/pre>
&lt;/div>
&lt;/p>
&lt;p>Now I can remove the plugin and lazy load the kubectl command every time I start up a new shell
session.&lt;/p>
&lt;p>Sometimes you don&amp;rsquo;t need a plugin for things, take each plugin you install seriously and check if
you really need it. A slow shell is not great and a killer for productivity.&lt;/p>
&lt;p>Source: &lt;a href="https://blog.mattclemente.com/2020/06/26/oh-my-zsh-slow-to-load.html">https://blog.mattclemente.com/2020/06/26/oh-my-zsh-slow-to-load.html&lt;/a>&lt;/p></content></item></channel></rss>