I think ... - shellhttps://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>Install the latest Zsh on CentOS2020-10-20T00:00:00+06:002020-10-20T00:00:00+06:00Khaled Monsoortag:blog.kmonsoor.com,2020-10-20:/install-latest-Zsh-on-CentOS/<p>If you’re trying to install the latest version of Zsh instead of the default old one, here you go.</p><p>As the <strong>default</strong> Zsh on CentOS is usually an older version, many cool things are not possible on this version of Zsh, like installing
<a href="https://ohmyz.sh/">oh-my-zsh</a> or using awesome <a href="https://github.com/romkatv/powerlevel10k">powerlevel10k</a> prompt system, it’s understandable if you’d like to have the latest Zsh on your system.
Easy peasy !! </p>
<p><strong>Note</strong>: Please remember to remove the <code>sudo</code> from the commands if you are already in “root” or sudo-er mode </p>
<p>We’ll be following these steps:</p>
<div class="toc">
<ul>
<li><a href="#install-the-pre-requisites">Install the pre-requisites</a></li>
<li><a href="#download-the-latest-source">Download the latest source</a></li>
<li><a href="#build-install">Build <span class="amp">&</span> Install</a></li>
<li><a href="#final-steps">Final steps</a></li>
<li><a href="#related">Related</a></li>
</ul>
</div>
<h1 id="install-the-pre-requisites">Install the pre-requisites<a class="headerlink" href="#install-the-pre-requisites" title="Permanent link">¶</a></h1>
<p>We need <span class="caps">GCC</span> (C++ compiler) and other related stuffs for building Zsh from the source code. </p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo yum groupinstall <span class="s2">"Development tools"</span>
<span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo yum install ncurses-devel
</code></pre></div>
<p>Now, check if <span class="caps">GCC</span> is installed properly, by<br>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>gcc -v
</code></pre></div></p>
<h1 id="download-the-latest-source">Download the latest source<a class="headerlink" href="#download-the-latest-source" title="Permanent link">¶</a></h1>
<p>Now, we gonna get the latest code of Zsh.<br>
Please update the link (in the shown command) with the latest by checking <a href="https://www.zsh.org/pub/">this web-folder</a>.<br>
Don’t forget to update the filename as well, if needed.</p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span><span class="nb">cd</span> /usr/local/src
<span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo curl -L https://www.zsh.org/pub/zsh-5.8.tar.xz <span class="se">\</span>
<span class="linenos" data-linenos="3 "></span>-o zsh-5.8.tar.xz
</code></pre></div>
<h1 id="build-install">Build <span class="amp">&</span> Install<a class="headerlink" href="#build-install" title="Permanent link">¶</a></h1>
<p>Unzip the file, “dig in” to the folder, and build <span class="amp">&</span> install from the source. </p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo tar -xf zsh-5.8.tar.xz <span class="c1"># the actual version of the downloaded file might be different</span>
<span class="linenos" data-linenos="2 "></span><span class="gp">$ </span><span class="nb">cd</span> zsh-5.8
<span class="linenos" data-linenos="3 "></span><span class="gp">$ </span>sudo ./configure <span class="o">&&</span> sudo make <span class="o">&&</span> sudo make install
</code></pre></div>
<h1 id="final-steps">Final steps<a class="headerlink" href="#final-steps" title="Permanent link">¶</a></h1>
<p>Add Zsh to the login shells by adding ‘/usr/local/bin/zsh’ on the last line of the config file, <code>/etc/shells</code> </p>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo -e /etc/shells
<span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>sudo chsh <span class="nv">$USER</span>
</code></pre></div>
<p>Update the system’s default symlink to the new Zsh version.<br>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo ln -sf /usr/local/bin/zsh /bin/zsh
<span class="linenos" data-linenos="2 "></span><span class="gp">$ </span>zsh --version
</code></pre></div></p>
<p>It’s always a good habit to clean up after doing stuffs. ;)
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="gp">$ </span>sudo make clean
</code></pre></div></p>
<p>That’s it !</p>
<p><img alt="voila" class="noZoom" src="https://i.imgur.com/BEFIOXfm.jpg"></p>
<h1 id="related">Related<a class="headerlink" href="#related" title="Permanent link">¶</a></h1>
<p>Want to have a super, cool-looking command shell? Gotcha, fam.
Check out my blog on <strong><a href="https://blog.kmonsoor.com/pimp-up-my-terminal/">Pimping up My Linux Terminal</a></strong>.</p>
<hr>
<p>If you find this post helpful, you can show your support <a href="https://www.patreon.com/kmonsoor">through Patreon</a> or <a href="https://paypal.me/KhaledMonsoor/">Paypal</a> or by <a href="https://ko-fi.com/kmonsoor">buying me a coffee</a>. <em>Thanks!</em></p>