I think ... - CLIhttps://blog.kmonsoor.com/2021-03-31T00:00:00+06:00How do I Pimp up My Terminal on Linux2021-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&nbsp;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&rsquo;d be some cherries on&nbsp;top.</p> <p>This command prompt in the below image is the end&nbsp;goal.</p> <p><img alt="The end goal of this post" src="https://i.imgur.com/YqnBifw.png"></p> <p>Assuming I&rsquo;m on a standard Linux machine with Ubuntu and I have <span class="caps">CLI</span> access. For other Linux distros or <em>MacOS</em>, some commands might be slightly&nbsp;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">&para;</a></h2> <p>While on some Linux systems, Zsh is present by default, on some it&rsquo;s not the case. So, let&rsquo;s make sure about&nbsp;it.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ sudo apt install zsh </code></pre></div> <p>Confirm the version. Oh-my-zsh recommends Zsh to be <code>5.0.8</code> or&nbsp;higher.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ zsh --version <span class="linenos" data-linenos="2 "></span>zsh 5.8 (x86_64-ubuntu-linux-gnu) </code></pre></div> <p>Also, you gotta make sure that <code>git</code> (recommended v2.4.11 or higher) is also installed on the&nbsp;system.</p> <h2 id="step-2-install-oh-my-zsh-the-fun-configuration-framework">Step-2: Install Oh-my-zsh, the fun &ldquo;configuration&rdquo; framework<a class="headerlink" href="#step-2-install-oh-my-zsh-the-fun-configuration-framework" title="Permanent link">&para;</a></h2> <p>Install directly from the&nbsp;source.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ sh -c &quot;$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)&quot; </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&nbsp;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&rsquo;s pimp up the prompt. Shall&nbsp;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">&para;</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&nbsp;awesome.</p> <p>Let&rsquo;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>$ git clone --depth=1 \ <span class="linenos" data-linenos="2 "></span> https://github.com/romkatv/powerlevel10k.git \ <span class="linenos" data-linenos="3 "></span> ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/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&nbsp;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">&para;</a></h2> <p>In this step, I&rsquo;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># deleting the current one &amp; get my personal one from GitHub <span class="linenos" data-linenos="2 "></span>$ rm .zshrc <span class="linenos" data-linenos="3 "></span>$ <span class="linenos" data-linenos="4 "></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&rsquo;t complain if I use the config file early. Have to set <code>ZSH_THEME="powerlevel10k/powerlevel10k"</code> in the <code>~/.zshrc</code> as&nbsp;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&nbsp;shell.</p> <p>Now is the time to enable the changes by restarting Zsh and enjoy the new config and the powerful&nbsp;prompt.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ exec zsh </code></pre></div> <h2 id="optional">Optional<a class="headerlink" href="#optional" title="Permanent link">&para;</a></h2> <p>Also, I usually install this very useful, but external plugin <code>fast-syntax-highlighting</code> for&nbsp;oh-my-zsh.</p> <div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span>$ git clone https://github.com/zdharma/fast-syntax-highlighting.git \ <span class="linenos" data-linenos="2 "></span> ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting </code></pre></div>