WHAT IS A COMMAND LINE INTERFACE (CLI)?
A CLI is basically a program that allows computer users to perform a task on a computer by typing in some custom commands. These programs were very popular and widely used in the 1960’s as the main input device for computers was the keyboard. Early operating systems (OS), like the Microsoft Disk Operating System (M-DOS), employed CLI as its basic working environment.
What this means is that you’re going to use CLI commands to accomplish every task on the operating system. The use of CLIs declined after the invention of Graphical User Interfaces (GUIs), i.e., windowing environments. Many modern OSs provide a combination of CLI and GUI. Hence, you can work with both on the same operating system.
"But wait a minute. So, what exactly is a shell?"
A shell acts like a backend for CLI commands. It reads and interprets every command input and then instructs the operating system to carry out the corresponding task tied to the command. There are numerous types of CLI shells in existence.
However, the two most popular and widely used shells are bash (for Linux and Unix-based operating systems) and Windows Shell (for Microsoft Windows). We’ll be focusing more on bash in this article. You can also get bash up and running on Windows by following this guide on how to install bash on Windows.
You can accomplish the following tasks using only your system’s shell :
- 🗄 Opening and closing programs and files
- 📁 Managing files and directories
- ⌨️ Controlling computer processes
- ✅ Performing administrative tasks
- 🔂 Automating repetitive tasks
ADVANTAGES OF CLI OVER GUI
You may be wondering why people still use CLI over GUI. Despite the simplicity that windowing systems offer. You’ll be cleared on this section.
Below are some reasons why many computer geeks prefer working on the CLI compared to GUIs.
1. USER-FRIENDLY 🤷🏼♂️
Yeah, you read that right. Power system users find that CLIs are very user-friendly. They can easily get a program up and running with a few handy commands. That’s exactly why many developers or network administrators spend a quality amount of time configuring their command line environment. so as to ensure optimum performance.
2. POWERFUL 💪
The CLI is extremely powerful to the extent that you can access protected operating system files through it. provided you’re running the CLI as an administrator or super-user. These permissions are assigned through the CLIs too!
3. USE FEWER SYSTEM RESOURCES 💠
CLI programs make use of small system resources compared to their GUI counterparts. This is simply because the interface is based solely on text. You can process a document with a very minimal system’s resources compared to when you do the same with GUI-based programs.
4. AUTOMATE REPETITIVE TASKS ♻️
If you have worked with large files before, then you know the importance of automation. CLI programs allow you to walk through many files and folders easily, provided you use the right command. The amount of comfort this particular CLI feature offers is unbeatable.
5. SPEED 🏃🏽♂️
Getting things done on the CLI is extremely fast and precise. If you use the correct commands, the result is always amazing and appears immediately after you press the enter key.
Just see CLI commands as "shortcuts" on GUI programs. Clicking CTRL+S saves your file, whereas navigating through file menus for the save button consumes more time. That is the same power CLIs give you (but greater here, 🤭).
We have so far covered what CLIs are, their features, and their advantages over GUIs. We’ll take a deeper dive into bash in the next section.
BASH AND BEYOND: ZSH, NEOVIM, AND ANTIGEN SETUP
Bash is the default shell of Linux and Unix-based operating systems. Bash is very powerful, but it has some limitations that make it difficult for users to carry out some functions. One of Bash’s limitations is its lack of a good number of plugins and themes.
Zshell (zsh) aims to correct most of the limitations in bash. It is also built on top of the bash shell and offers plenty of plug-ins and themes. It also offers syntax highlighting, which makes it look very much like GUI-based Integrated Development Environments (IDEs).
We’ll talk more about Zsh and configurations in the next section.
INSTALLATION AND CONFIGURATION OF ZSH
It’s very easy to set up Zsh on Linux-based operating systems. The process is the same on Windows too, if you have installed Ubuntu or Debian on your Windows Subsystem for Linux. We can install zsh by following the steps :
1. UPDATE YOUR SYSTEM’S PACKAGES AND DEPENDENCIES
This is where many people get it wrong. If this is your first time using your terminal, it is highly advisable that you update and upgrade all the packages and dependencies before using the "superuser do" command, i.e., sudo. You can accomplish the task by using :
sudo apt update && sudo apt upgrade
Wait till the process finishes before proceeding to the next step 🚀.
2. INSTALL THE Z SHELL
All you have to do is to use the commands below on your terminal to get zsh up and running.
- Installing on Mac
brew install zsh
- Installing on Ubuntu and Debian
sudo apt-get install zsh
The commands can be used to install zsh on bash running on Ubuntu and Debian kernels or subsystems. You can also see how to install zsh on other platforms by visiting their official zsh installation documentation.
You can now check if zsh installation was successful by entering the commands below :
zsh --version
You should get an output similar to the one in the image below.
We can configure zsh to be our default shell by using :
chsh -s $(which zsh)
You can also switch back to Bash using :
chsh -s $(which bash)
Running the /.zshrc file on zsh will open the configuration files created automatically during zsh installation. You can make some changes here but be sure that you’re sure of what you’re doing! 🔥
OH MY ZSH CONFIGURATION
We’re done with the installation of Zhs. It is now time to install Oh My Zsh. What this package does is act as a manager for zhs config files. Apart from that, it also comes with bundles of helpful functions, plugins, and themes.
Sounds cool, right? 😍 Let's get it working on our terminal!
Follow the steps below to install Oh My Zsh setup
1. INSTALL GIT
The first step is to check if git is installed. If not, just follow the steps below to install it. This is very important because we’ll be cloning a Github repository in order to install Oh My Zsh on our system.
sudo apt-get install git
You can verify git’s installation by typing the command below.
git --version
2. INSTALL OH MY ZSH
After installing git, getting Oh My Zsh up and running on your terminal is super simple.
All you have to do is to enter any of the commands and URLs below :
# curl
sh -c "$(curl -fsSL <https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh>)"
# wget
sh -c "$(wget -O- <https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh>)"
# fetch
sh -c "$(fetch -o - <https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh>)"
From our post-installation message, you can see that Oh My Zsh created a backup of our .zshrc file, then replaced it with its own version.
This is what it looks like when you open ~/.zshrc files. You can see that the only plugin we have so far is git. We’ll add more in a later section.
If you open the ~/.zshrc file, you’ll see a line named ZSH_THEME
. You can change your terminal theme through it.
Provided the theme is installed on your system, it sounds cool, right? That’s just one of the cool things we can do with Oh My Zsh. Adding the line in the image below will get you any theme you want 🔥
NEOVIM EDITOR INSTALLATION AND CONFIGURATION
Neovim is basically a nice text editor that adds more features to the built-in Vim editors on Linux. One of the main reasons it is so popular among developers is its extensive plugin support.
Follow the steps below to get Neovim up and running 🚀
1. DOWNLOAD AND INSTALL NEOVIM
The step is the same with all the CLI programs we’ve talked about so far.
- Installing on a Mac
brew install neovim
- Installing on Ubuntu and Debian
sudo apt-get install neovim
You can look up guides on how to install neovim on other operating systems here. You should then get a page that looks like this if the Neovim installation goes as expected.
2. NEOVIM CONFIGURATION
Neovim config files give us the power to control how things function in our editor environment. The configuration process is very easy. In fact, neovim config files can be set with a few clicks 😋.
Neovim config files do not come by default. Hence, you have to create it by yourself. You can create this file by following these commands.
# create .config directory
mkdir .config
# cd into the .config directory
cd .config
# create nvim directory
mkdir nvim
# cd into the nvim directory
cd nvim
# init nvim
nvim init.vim
You can then add your config files here. One of the most useful lines in a config file is :set number
, which adds a numbering feature to your editor. You can save the file by clicking on the esc key and then typing :w
to write the file to disk.
Below is a simple Neovim config file :
" Options :set background=dark:set number:set relativenumber:set autoindent:set tabstop=4:set shiftwidth=4:set smarttab:set softtabstop=4:set mouse=a
LUNARVIM INSTALLATION AND CONFIGURATION
LunarVim provides intellisense support for Neovim 😍.
It provides an IDE layer for Neovim with some incredible default configuration.
1. LUNARVIM INSTALLATION
Before proceeding with the installation. Please make sure that you're on nvim folder. The installation is also very basic. Just run the command below.
bash <(curl -s <https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh>)
You'll get LSP
support automatically after running this command! 😱
The image below shows LunarVim in action with the Neovim editor.
You can learn more about this powerful tool on their official getting started documentations.
2. LUNARVIM CONFIGURATION
Like mentioned previously, most of the features you need in LunarVim are already enabled by default. You can also play around with LunarVim config files by tweaking lvims config file :
lvim ~/.config/lvim/config.lua
Antigen Installation and Configuration
Antigen has withstood the test of time as one of the most stable Zsh plugin managers, called bundles.
We will install a couple of these plugins here. Without wasting much time, let’s get started with Antigen.
1. INSTALL ANTIGEN
You can get antigen installed on your system by using the following commands:
curl -L git.io/antigen > antigen.zsh
2. CONFIGURING ANTIGEN
The configuration process is basically very easy 👍.
All you have to do is to load antigen files into Oh My Zsh. You can do that by opening the .zshrc file with Neovim and then add the plugins you need. The configuration file below is a default sample after installation.
source /Users/[yourUserName]/antigen.zsh
# load the oh-my-zsh's library.
antigen use oh-my-zsh
# bundles from the default repo (robby russell's oh-my-zsh).
antigen bundle git
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle lein
antigen bundle command-not-found
# syntax highlighting bundle.
antigen bundle zsh-users/zsh-syntax-highlighting
#Load the theme.
antigen theme robbyrussell
# tell antigen that you're done.
antigen apply
What this does is that it adds git, zsh-autosuggestions, lein, zsh-syntax-highlighting, and command-not-found plugins to our workspace! ❤️
Here are some popular Antigen Parameters that you can use to spice things up.
You can add other plugins by simply using the command below :
antigen bundle {repoURL}
Adding antigen apply after inserting the command will make antigen grab the necessary files for that plugin. It will be loaded when you relaunch your terminal 🦾.
TMUX SETUP AND CONFIGURATION
If you have used GNU Screen before, then you know exactly what Tmux is. Tmux is basically an open-source terminal multiplexer for Linux and Unix-based operating systems.
It allows you to open multiple terminal sessions, which can be accessed simultaneously in a single window 🧑🎨.
This tool is very important if you want to run more than two processes on your terminal at the same time.
Follow the steps below to get started with Tmux :
- Installing on Mac
brew install tmux
- Installing on Ubuntu or Debian
sudo apt-get install tmux
You can check tmux’s official documentation on GitHub for how to install it on other operating systems.
TMUX CONFIGURATION
Configuring tmux is quite simple. Just use your favorite text editor to open ~/.tmux.conf. If the file already exists, you can make some changes. If not, your text editor will create it as a new file. You can insert and save your configuration file here.
You can use the config file below to spice up your tmux workspace 🌶.
# improve colors
set -g default-terminal 'screen-256color'
# set scrollback buffer to 10000
set -g history-limit 10000
# customize the status line
set -g status-fg green
set -g status-bg black
TMUX COMMANDS
Tmux, just like every other CLI program, has its own unique commands. The image below shows a list of some basic Tmux commands.
STARTING TMUX
Just enter the command below to start Tmux after installation :
tmux
ADDING A NAME TO A TMUX SESSION
Running only tmux creates sessions identified numerically. You can create a session with a name by simply typing the command below :
tmux new -s sessionName
CREATING PANES IN TMUX
Tmux panes help you to easily navigate between sessions. You can create both horizontal and vertical panes by using the commands below, respectively.
HORIZONTAL & VERTICAL PANE KEYBOARD SHORTCUTS
# horizontal pane
Ctrl+b %
# vertical pane
Ctrl+b "
A combination of Tmux and Lunarvim gives you incredible power over your terminal.
To learn more about Tmux, try out the Tmux commands I listed earlier.
AUTOJUMP INSTALLATION AND USAGE
Autojump is a Zsh plugin that can help you easily navigate through the file system.
You can access your system's directory and subdirectory easily using autojump.
AUTOJUMP INSTALLATION
- Installing on Mac
brew install autojump
- Installing on Ubuntu and Debian
sudo apt-get install autojump
- Or manually by cloning the autojump repo
git://github.com/wting/autojump.git
For other operating systems, please see the Autojump installation documentation.
AUTOJUMP USAGE
Autojump provides some convenient command wrappers. You can get things done with these short commands.
Below are some of them.
j # jumps to a directory
For instance, we can use j to open a directory that contains pineapple.
j pineapple # jump to a directory
We can use jc to jump to the child directory (i.e subdirectory) of our current directory.
We will use the jc command to open a subdirectory that contains a banana in it.
jc banana
This next autojump command enables you to open a directory with file managers instead of a terminal :
jo banana
And finally, navigate to subdirectories in the file manager using :
jco banana #
ALACRITTY INSTALLATION, SETUP, AND USAGE
We have been using our default terminal all this while. It is now time to go GODMODE
with Alacritty.
You may be wondering what Alacritty is. It is an OpenGL-powered, modern, and powerful terminal emulator.
Alacritty provides many features out of the box. So you don’t have to worry about Alacritty config files as most of them come by default. Research has shown that Alacritty is one of the fastest terminal emulators out there.
1. ALACRITTY INSTALLATION
You can get Alacritty up and running with the following commands :
- Clone Alacritty Repository
git clone <https://github.com/alacritty/alacritty.git>
- Go inside of the cloned directory
cd alacritty
- Install Rust Compiler With Rustup
curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs> | sh
- Confirm and update your rustup packages
rustup override set stable
- Update rustup
rustup update stable
2. INSTALL ALACRITTY UBUNTU DEPENDENCIES
Alacritty needs some files to run efficiently. You can get all the dependencies you need to get started with Alacritty by running the command below :
sudo apt-get install cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3
This will take some time to finish loading. But everything should be fine after it finishes running ✨
3. BUILDING ALACRITTY ON UBUNTU
We are almost at the final step ! 😊 Let's build an Alacritty terminal emulator on our Ubuntu machine !
Type in the command below.
cargo build --release
You may get an error that cargo is not recognized as a Zsh command. That error can be fixed by just running :
sudo apt-get install cargo
After installing cargo, You can try cargo build --release again.
Confirm Alacritty installation by running :
alacritty --v
And besides, you'll binary at target/release/alacritty if the installation goes well.
4. CREATING A DESKTOP SHORTCUT FOR ALACRITTY
Shortcuts will help you access programs faster. Hence, we'll be creating a desktop shortcut for this awesome tool. Below are the steps :
sudo cp target/release/alacritty /usr/{**local**}/bin
sudo cp extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
sudo desktop-file-install extra/linux/Alacritty.desktop
sudo update-desktop-database
You can access Alacritty from the shortcut we created.
5. ALACRITTY CONFIGURATION
Just click on the shortcut we have created to open Alacritty. 🧑🏽💻
- Copy Alacritty's default configuration.
mkdir -p ~/.config/alacritty
cp /usr/share/doc/alacritty/example/alacritty.yml ~/.config/alacritty/alacritty.yml
- Open and edit Alacritty config files with lvim! 🤘
~/.config/alacritty/alacritty.yml
Most of Alacritty's config files come by default.
You can enable it by uncommenting the line you want to activate. You can also add your own config files.
You can also use this Lunarvim config file to fire up your Alacritty :
CONCLUSION
We have so far covered what CLIs and GUIs are, the installation and configuration of Zsh, Neovim, Alacrity, etc.
The tools we used here will make you fall in love with the terminal and never go back to your windowing interface.
This is simply because they'll give you all the tools you may miss in your windowing interfaces. For instance, Lunarvim gives your terminal-based text editor the same ecosystem your GUI-based IDEs provide, with minimal system resources.
Hence, speeding up your system's performance and increasing your productivity as well!
Thank you for staying all the way to this point!