I think ... - terminalhttps://blog.kmonsoor.com/2021-03-31T00:00:00+06:00Pimping up My Linux Terminal2021-03-31T00:00:00+06:002021-03-31T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2021-03-31:/pimp-up-my-terminal/<p>How do I pimp up my Linux terminal? A quick trip through Zsh, Oh-my-zsh, and other power tools to make the command-line-based workflow smooth and cool.</p><p>The purpose of this post is to be my quick, copy-paste source of the commands that I use to set up my terminal on a new *nix system.
However, if someone else finds it useful, that’d be some cherries on top.</p>
<p>This command prompt in the below image is the end goal.</p>
<p><img alt="The end goal of this post" src="https://i.imgur.com/oZahIog.png"></p>
<p>Assuming, I’m on a standard pc/server with Ubuntu Linux and I have <span class="caps">CLI</span> access with <code>sudo</code>. For other Linux distros or <em>MacOS</em>, some commands might be slightly different.</p>
<h2 id="step-1-confirm-that-zsh-is-up-to-date">Step-1: Confirm that Zsh is up-to-date<a class="headerlink" href="#step-1-confirm-that-zsh-is-up-to-date" title="Permanent link">¶</a></h2>
<p>While on most of the Linux systems Zsh is present by default, on others that’s not the case. So, let’s make sure about it.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo apt install zsh
</code></pre></div>
<p>Confirm the version. <code>Oh-my-zsh</code> recommends Zsh to be <code>5.0.8</code> or higher.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>zsh --version
<span class="linenos" data-linenos="2 "></span><span class="go">zsh 5.8 (x86_64-ubuntu-linux-gnu)</span>
</code></pre></div>
<p>Also, you gotta make sure that <code>git</code> (recommended v2.4.11 or higher) is also installed on the system.</p>
<h2 id="step-2-install-oh-my-zsh-the-fun-configuration-framework">Step-2: Install Oh-my-zsh, the fun “configuration” framework<a class="headerlink" href="#step-2-install-oh-my-zsh-the-fun-configuration-framework" title="Permanent link">¶</a></h2>
<p>Install directly from the source.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sh -c <span class="s2">"</span><span class="k">$(</span>curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh<span class="k">)</span><span class="s2">"</span>
</code></pre></div>
<p>In the last step of this installation, it will ask to set Zsh as <span class="caps">THE</span> shell. Go ahead.</p>
<p>Now we have the default prompt from <code>Oh-my-zsh</code>. </p>
<p><img alt="After successful installation of Oh-my-zsh" src="https://i.imgur.com/HOVqqvi.png"></p>
<p>Now, let’s pimp up the prompt. Shall we?</p>
<h2 id="step-3-install-powerlevel10k-a-powerful-prompt-theme">Step-3: Install <code>powerlevel10k</code>, a powerful prompt theme<a class="headerlink" href="#step-3-install-powerlevel10k-a-powerful-prompt-theme" title="Permanent link">¶</a></h2>
<p>I love the powerful Zsh theme <code>powerlevel10k</code>. More on <a href="https://github.com/romkatv/powerlevel10k#features">why this theme</a> is awesome.</p>
<p>Let’s install it on top of <code>oh-my-zsh</code>.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>git clone --depth<span class="o">=</span><span class="m">1</span> <span class="se">\</span>
<span class="linenos" data-linenos="2 "></span> https://github.com/romkatv/powerlevel10k.git <span class="se">\</span>
<span class="linenos" data-linenos="3 "></span><span class="gp"> $</span><span class="o">{</span>ZSH_CUSTOM:-<span class="nv">$HOME</span>/.oh-my-zsh/custom<span class="o">}</span>/themes/powerlevel10k
</code></pre></div>
<p>Now, gotta set <code>ZSH_THEME="powerlevel10k/powerlevel10k"</code> in <code>~/.zshrc</code> by adding that manually in the file.</p>
<h2 id="step-4-make-sure-the-prompt-looks-like-as-you-want">Step-4: Make sure the prompt looks like as you want<a class="headerlink" href="#step-4-make-sure-the-prompt-looks-like-as-you-want" title="Permanent link">¶</a></h2>
<p>In this step, I’m gonna bring in my already open-sourced Zsh config file aka <code>.zshrc</code>. </p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp"># </span>deleting the current one <span class="p">&</span> get my personal one from GitHub
<span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>rm .zshrc
<span class="linenos" data-linenos="3 "></span><span class="gp">$</span>
<span class="linenos" data-linenos="4 "></span><span class="gp">$ </span>wget https://raw.githubusercontent.com/kmonsoor/dot-files/master/.zshrc
</code></pre></div>
<p>I kept the powerlevel10k configs as comments so that Zsh doesn’t complain if I use the config file early.
Have to set <code>ZSH_THEME="powerlevel10k/powerlevel10k"</code> in the <code>~/.zshrc</code> as well.</p>
<p>Otherwise, once the <code>powerlevel10k</code> theme will run for the first time by Zsh, a very friendly step-by-step prompt will run you through towards a desirable prompt for you. Also, whenever you want, you can invoke the config-wizard by executing <code>p10k configure</code> on the shell.</p>
<p>Now is the time to enable the changes by restarting Zsh and enjoy the new config and the powerful prompt.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span><span class="nb">exec</span> zsh
</code></pre></div>
<h2 id="optional">Optional<a class="headerlink" href="#optional" title="Permanent link">¶</a></h2>
<p>Also, I usually install this very useful, but external plugin <code>zsh-syntax-highlighting</code> for oh-my-zsh.</p>
<p><div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>git clone https://github.com/zsh-users/zsh-syntax-highlighting.git <span class="si">${</span><span class="nv">ZSH_CUSTOM</span><span class="k">:-</span><span class="p">~/.oh-my-zsh/custom</span><span class="si">}</span>/plugins/zsh-syntax-highlighting
</code></pre></div>
Don’t forget to activate the plugin by including it in ~/.zshrc. For that, add <code>zsh-syntax-highlighting</code> inside the list of other plugins.</p>
<p>plugins=( plugin_a plugin_b zsh-syntax-highlighting)</p>