Linux Commands

Beautifying Bash and Vim Using oh-my-bash and Nightfly

Bash and Vim are one of the most popular comfort tools for developers and Linux users. This arises the need to beautify the tools users spend most of their time with. Something that not only brings aesthetics to the tool but renders some useful plugins and functionalities as well.

In this tutorial, you will learn to beautify your vim and bash tools with the help of Nightfly and oh-my-bash.

Beautifying Bash via oh-my-bash

Being a handy fork of the renowned oh-my-zsh, Oh-my-bash is an open-source framework for Bash users that is teeming with colorful themes, smart templates, useful plugins, functions, aliases, and so much more that adds to the beauty of the bash. We will be discussing how we can install and use this framework as per our likings.

Getting Started

Use curl or wget to begin the installation process.

Ctrl+Alt+T to start the terminal and type any of the following commands.

For curl users:

ubuntu@ubuntu:~$ bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"

For wget users:

ubuntu@ubuntu:~$ bash -c "$(wget https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh -O -)"

The execution of the above commands yields a colorful message that confirms the successful installation of oh-my-bash.

Oh-my-bash Themes and Plugins

This screen output gives you a chance to play with the framework and explore all the themes, plugins, and other functionalities it supports. Since we aim to learn how to beautify the bash, let’s get started with the lovely themes it offers.

To change the themes, choose any available themes in the themes folder. Select any name and open the ~/.bashrc file in your favorite editor. We have been using vim as follows:

ubuntu@ubuntu:~$ sudo vim .bashrc

Here, in this file, look for the following line of code:

OSH_THEME="font"

Replace this “font” with the name of the theme you want to choose. For instance, to apply agnoster, it should look like:

OSH_THEME="agnoster"

This allows users to test and try various themes and choose one that goes with their mood. If you want to keep it cool and charming or if you’re too tired to select one, you can go with “random”. This will keep on changing the themes every once in a while, and your bash will never be the same old boring one.

OSH_THEME="random"

Source the ~/.bashrc file to apply recent changes:

ubuntu@ubuntu:~$ sudo source .bashrc

Oh-my-bash is not about themes only. You can also try various useful plugins. Using these plugins is as easy as applying any of its themes. You just have to mention the plugins you want to use in the ~/.bashrc file and you’re good to go!

For instance, we add git, aws, and brew to the plugins list in the file as follows:

plugins=(git brew aws)

This way you have a highly attractive bash ready for you.

Uninstalling oh-my-bash

In order to uninstall this framework and get back to the default shell, you just have to execute the following command:

ubuntu@ubuntu:~$ ./uninstall_oh_my_bash

The framework will be removed from your pc and previous bash configurations will be reverted. Now, let’s get to the beautification of Vim editor.

Beautifying Vim via Nightfly

Nightfly is one of the most attractive color schemes offered for Vim editors. In order to get that theme on your system, you need to have your favorite plugin manager installed.

The installation of a plugin manager enables users to include plugins that add a lot of functionality and aesthetics to the system. There are a good number of managers available like Dein, Vundle, Vim-plug or Pathogen, etc.

However, in this tutorial, we will be using Vim-plug, as it is one of the easiest and most reliable plugin managers for vim editor. In order to have that fancy vim look, we install the vim-plug manager as follows.

Install vim-plug using the following command:

ubuntu@ubuntu:~$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Once installed, it’s all set to use in order to add the plugins and color schemes you want. The aim is to beautify the vim editor to make it look more captivating. Hence, now, we will see how to apply Nightfly with the help of vim-plug, which is one of the most popular dark-themed color schemes for vim.

Follow the steps mentioned below to download the Nightfly scheme in the .vim directory.

Begin with creating the directory named plugged in the .vim folder as follows:

ubuntu@ubuntu:~$ cd .vim

ubuntu@ubuntu:~$ mkdir plugged

Now cd into the directory and git clone the color scheme via git as follows:

ubuntu@ubuntu:~$ git clone https://Github.com/bluz71/

vim-nightfly-guicolors.git

Now that we are all done with the installation of Nightfly, we just have to apply it.

First of all, open the ~/.vimrc file, but if you don’t have it yet, create one by adding a vim-plug section inside it.

Start your section by adding the following function:

call plug#begin(‘~/.vim/plugged’)

Add the desired plugin or scheme using the plug command:

Plug 'bluz71/vim-nightfly-guicolors'

set termguicolors

Then close the function with:

call plug#end()

Now run this file in vim using:

:PlugInstall

Lastly, at the end of the plug declaration, add the name of the color scheme you are going to apply.

For Nightfly, write:

colorscheme nightfly

Plug 'bluz71/vim-nightfly-guicolors'

This is how the ordinary python code changes colors:

And the following screenshot will show a C++ code.

Run this file. Then, restart your vim, and in front of you is a vim window with dark mode and colorful code on it. You can experiment with some other themes with the help of these few easy steps. Similarly, you can explore other plugins as well.

Conclusion:

Bash and vim are a vital part of developers’ toolkits in Linux. That raises the urge to beautify these everyday tools and make them look pleasant and impressive. Those who don’t know might think they need some set of expertise to build an impressive terminal. However, a pretty shell and editor are just a few commands away. All you have to do is download the oh-my-bash framework and Nightfly scheme and configure them as per your likings. Then let them do the wonders!

About the author

Usama Azad

A security enthusiast who loves Terminal and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I’m born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National University of Science and Technology (NUST). On Twitter i go by @UsamaAzad14