Bash-it : Bash Framework to Make Your Terminal Cool

Like Oh My Zsh but for Bash. Beautify your Linux terminal while keeping your favorite bash shell with Bash-it framework. Learn all about using it.
Warp Terminal

Have you ever thought the default appearance of your terminal to be a little mundane? Or ever wished for having a bit more control over your terminal workflow?

Many Linux users resort to Zsh with its Oh My Zsh plugin. But if you want to stick with the evergreen bash shell, I have got just the right tool for you, Bash-it.

Just ensure that you are running Bash shell. Run the following command and see if you see YES:

[ -n "$(echo $BASH)" ] && echo YES || echo NO

Now that you know, you are using Bash or not, letโ€™s dive into the main topic.

๐Ÿ“‹
This article is intended for at least intermediate level Linux users who would know their way around Shell and its configuration. Beginners may try it at their own risk.

Bash-it Features

Bash-it is a Bash framework for using, developing and maintaining various shell scripts, custom commands, aliases and more. It is a community-driven project on GitHub. So, everything you find in it is used & tested by thousands of people and developed by many contributors.

Aliases

Bash-it comes with a huge collection of aliases used by the community. Currently, 48 alias scripts are available. To list all the aliases, use:

bash-it show alias

You can enable/disable them by:

bash-it enable alias apt
bash-it disable alias git
Some  alias for apt commands has been added to the bashrc file by Bash_it.
Alias for APT added

You can search for any aliases for a particular programming language or environment using:

bash-it search apt
Bash-it search for available alias/completions for APT command.
Search for APT Alias/Plugins/Completions

Completion

Typing the whole command every single time is painful. Most of the command-line tools on Linux enable completion while installing them. So, that if you write the first two or three letters on the terminal and hit TAB, it is auto-completed.

But not all of them have it enabled. For many command-line tools, the completion scripts are written by the community developers rather than the official source.

Bash-it has a collection of those, and it gives you an easy way of enabling/disabling them:

bash-it enable completion ssh
bash-it disable completion pip

You should enable system completion for loading completion scripts provided by the system and bash-it for bash-it command completion.

Like alias, you can search if completion exists for a particular tool using:

bash-it search pip

If there is a completion available, it will be listed.

List completions available for a tool. Here, pip completions are listed. Note that, there is also some plugins available for pip, but we are looking at completions.
List Completions/Plugins/Aliases

Similarly, you can list all the completions and there enabled/disabled status using:

bash-it show completions
List all the completions available along with the enable/disable status in Bash_it.
Show Completions

Plugins

Bash-it comes with a bunch of plugins for various tools and purposes. Currently, there are 83 plugins available. Generally, plugins may contain:

  • Helper functions for performing various complex tasks easily. E.g.: extractgitrailsssh etc.
  • Initialization & configuration scripts that prepare tools to be ready to use. E.g.: fasdgonodenvmrbenv etc.
  • Dependencies for other parts of bash-it. E.g.: alias-completionbasebattery etc.

The alias-completion plugin is needed to be enabled for the completion scripts to work properly. Also, you should enable the base plugin as some other plugins depend on it.

To list all the available plugins along with the enabled/disabled status, use the command:

bash-it show plugins
List all the available plugins along with the enabled/disabled status in Bash-it.
Show Plugins

Now the commands for enabling/disabling plugins are similar to what we saw before.

bash-it enable/disable plugin <plugin-name>

A cool plugin in sudo:

bash-it enable plugin sudo
bash-it reload

What it does is, insert sudo to the beginning of the current or previous command. All you have to do is, press ESC key twice.

0:00
/0:21

Bash-it sudo plugin. Press the ESC key twice to add sudo to the current or previous command

Themes

This is the cool part. Bash-it currently has several themes available by default for your Bash prompt. Hereโ€™s how the Ubuntu vanilla Bash prompt looks like:

Vanilla Bash_it theme is bobby.
Default Bash_it Theme

Bash-it themes can show various useful information in your prompt, like:

  • Git repository and other version control system information
  • Python and Ruby version
  • Time, battery information and so on!

Cool, isnโ€™t it?

You can visit the official documentation to get a visual overview of all the available themes.

Once you like a particular theme, preview it on your terminal using:

bash-it preview <theme-name>

To make it permanent, open your ~/.bashrc~ file in a text editor of your choice.

nano ~/.bashrc

Now, change the value of the BASH_IT_THEME variable to the name of the theme you have chosen.

Change Bash-It Theme

Once done, use the command below to reload.

bash-it reload

That's it! The new prompt theme will be visible for you.

Bash-it with an eye-candy theme (Metal) installed
Bash_It Metal Theme

Some Extra Features

Let's see some cool settings to make Bash_it looks better.

Command execution duration

You can enable the last command execution time by setting the value of BASH_IT_COMMAND_DURATION variable to true. In the default configuration, this is true and the minimum time in seconds before command duration is displayed is set to 1. You can configure this by setting the COMMAND_DURATION_MIN_SECONDS variable.

๐Ÿšง
The theme should support command duration. Example barbuk theme.
export BASH_IT_COMMAND_DURATION=true
export COMMAND_DURATION_MIN_SECONDS=5
Command execution duration in Bash_it "barbuk" theme. Here, the minimum time settings was one seconds.
Command Duration

Minimal git details

To avoid slowdown of the prompt while working on large git repositories, use minimal Git details:

export SCM_GIT_SHOW_MINIMAL_INFO=true

Installing Bash-it

Bash-it is fairly popular but it is not available in the default repository of distribution. You can install it directly from the GitHub master branch.

Install Bash-it

The simplest way of installing Bash-it is running the following commands:

git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
cd ~/.bash-it
./install.sh

Install Bash_it in Ubuntu

๐Ÿšง
In the above video, we have followed the default and installed Bash_it by overwriting the current bashrc. You can choose the "y" option to append the bash-it templates at the end.

Bash-it can be used and installed in various fashion. For example:

  • Simply use the cloned repository (shown above).
  • Fork it on GitHub, clone it and modify it as you see fit.
  • Use it with a dotfiles manager, like โ€“ dotbot (thatโ€™s a discussion for another day).

You have to experiment with it to see how you feel comfortable.

For additional information, you can check the README file & Wiki. Even their GitHub page has plenty of information and instructions on using it.

Updating Bash_it

To update Bash_it, you can use the bash-it update command. If you have installed from the GitHub master branch as described in the article, you have the dev version. So, to check for update, run:

bash-it update dev

If you have installed it using the stable release from GitHub releases section, use:

bash-it update stable

Uninstall Bash-it

If you don't like Bash-it, you can remove it very easily. Open a terminal and run:

cd $BASH_IT
./uninstall.sh

Once the process is completed, remove the Bash_it folder you have cloned during install.

Uninstall Bash_It

Essential Bash_it commands

Now that you know how to install and use Bash_it, let's revise some important Bash_it commands:

Commands Description
bash-it update dev/stable Update the Bash_it installation
bash-it search <search-term> Find out which of the plugins, aliases or completions are available for a specific scenario.
bash-it reload Reload your Bash profile
bash-it restart Restart/rerun your shell (Bash)
bash-it doctor Reload your bash profile and print out logs of various parts in Bash-it
bash-it profile save my_profile Save current profile
bash-it profile load default Load default profile
bash-it profile load my_profile Load custom profile
bash-it show <item> Show a list of available <item> (alias/completion/plugin). Also gives enabled/disabled status.
bash-it enable <item> <item-name> Enable an alias, completion, etc. Here, <item> is alias/completion/plugin
bash-it disable <item> <item-name> Disable an alias, completion, etc. Here, <item> is alias/completion/plugin
bash-it preview <theme-name> Preview the mentioned theme

Is it worth trying?

You are kidding, right? Of course, it is. It might take you a while to figure out the workflow with Bash-it. But, in the long run, it helps a lot.

Are you going to give it a try? Have you tried Bash-it before? Share your thoughts with us.

About the author
Sreenath

Sreenath

Linux tinkerer by day, Lord of the Rings fanatic by night. When I'm not busy conquering the command line, you can find me kicking back and watching some football while quoting JRR Tolkien

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! Youโ€™ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.