Bash-It Framework to Control Your Scripts and Aliases
By Jithin on July 10th, 2020
Bash-it is a community-driven Bash framework to make your terminal look and act way cooler. This framework helps in maintaining various shell scripts, custom commands, aliases, and more. This framework comes with autocompletion, themes, aliases, custom functions, and more. Bash-it offers a useful framework for developing, maintaining, and using shell scripts and custom commands. You can use the Bash-it framework if you want to keep track of all your scripts, aliases, and functions you use daily.
Bash-it is a community-driven project on GitHub for Bash 3.2+. You can fork/clone Bash-it instead of flooding your ~/bin directory and your .bashrc file.
Install Bash-It in Linux
The first process to install Bash-it is to clone the following repository to a location of your choice, for example:
$ git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
Next, install Bash-it by running the following command. During installation, the system prompts, “would you like to keep your .bashrc and append bash-t templates at the end? [y/N]”, you can answer this prompt according to your preference. Depending on your operating system, it will automatically backup your ~/.bash_profile or ~/.bashrc.
This installation command should have output similar to the one shown below.
To verify the installation, you can use the ls command. This command displays all the bash-it installation files and directories.
$ ls .bash_it/
To start using the Bash_it framework, you can open a new tab or run the following command.
$ source $HOME/.bashrc
Customize Bash-it in Linux
To customize the Bash-it framework, you need to edit the modified configuration file, such as ~/.bash_profile or ~/.bashrc shell startup file. You can use the following commands to show all the installed and available aliases, completions, and plugins. These commands also show you how to enable or disable these aliases, completions, and plugins.
$ bash-it show aliases $ bash-it show completions $ bash-it show plugins
Let us see what are Aliases.
To list the current aliases, you can use the following command.
This above command should show an output similar to the one shown below in the screenshot.
The $HOME/.bash_it/aliases/ directory stores all the aliases. You can enable a particular alias using the following command.
$ bash-it enable alias <alias_type>
For example, if you want to enable the apt aliases, then you can use the following command.
$ bash-it enable alias apt
After running the above command, you need to reload the bash-t configuration by using the following command. After the reload, you can rerun the alias command to check if the apt aliases are enabled.
$ bash-it reload $ alias
To disable any of the alias types, then you need to run the following command. In this command prompts, if you want to remove the alias, and you can press ‘y’ to continue. After disabling the alias, you need to reload the bash-it configure to reflect the changes.
$ bash-it disable alias apt $ bash-it reload
Manage Bash-It Themes
The default Bash-it theme is ‘bobby’. To check the default theme, you can run the following command.
The $BASH_IT/themes directory stores over 50+ Bash-it themes. These themes can be listed using the ‘ls’ command.
$ ls $BASH_IT/themes
If you want to preview all the Bash-it themes before using it, then you can run the following command.
$ BASH_PREVIEW=true bash-it reload
You can change the default theme by editing the theme name in the .bashrc file. You need to find the following line in the file to make the changes.
$ vim ~/.bashrc export BASH_IT_THEME=’<theme_name>’
Suppose you want to use the theme named ‘essential’ instead of ‘bobby’, then you can open the .bashrc file and find the following line and make the changes. After that, save and close the file.
After saving the above file, you need to source it by running the following command.
$ source $HOME/.bashrc
If you have built any custom themes outside of $BASH_IT/themes directory, then you need to point the BASH_IT_THEME variable directory to that theme file in the .bashrc file.
If you want to disable themes in Bash-it, then you can edit the .bashrc file and then leave the BASH_IT_THEME environment variable empty.
How to Search Plugins, Aliases, or Completions in Bash-It
It is accessible to search which all plugins, aliases, or completions are available for a specific programming language, framework, or environment. You can do the same by just searching multiple terms related to some of the commands you use frequently.
$ bash-it search python pip pip3 pipenv $ bash-it search git
To view the help messages for the aliases, completions, and plugins, you can run the following commands.
$ bash-it help aliases $ bash-it help completions $ bash-it help plugins
To run your custom themes, you need to add the custom theme folder under the “./custom/themes” directory.
Custom Scripts, and aliases
If you want to load your custom scripts, then you create the script under the “./custom/” directory inside the bash-it folder.
Since Bash-it is a community-driven project, you can add your custom scripts to the main project on GitHub. In this way, anyone who wishes to use your script can use that from the GitHu. By sharing the scripts, the Bash-it grows better.
You can create your custom scripts and aliases under the following files in the respective directories. You need to save the custom files with the “.bash” extension, to make sure that Bash-it loads it.
- custom/themes//<custom theme name>.theme.bash
Updating and Uninstalling Bash-It
If you want to update Bash-it to the latest version, then you can run the following command.
$ bash-it update
If you want to uninstall Bash-it, then you should run the following commands.
$ cd $BASH_IT $ ./uninstall.sh
If you run the ‘uninstall.sh’ script, then this script automatically restores your previous Bash startup file. After the uninstall script runs, you should remove the Bash-it directory from the system by running the following command.
$ rm -rf $BASH_IT
After removing the Bash-it directory, you need to start a new shell for the recent changes to work, or you can source the .bashrc by running the following command.
$ source $HOME/.bashrc
Also, you can use the help command to see all the Bash-it usage options.
$ bash-it help
Bash-it is an easy way to keep track of all your ash scripts and aliases. It comes with several cool features related to Git, and you can see the same under the Bash-it GitHub repository. The Bash-it is a framework that can be used to manage and develop different scripts, aliases, and plugins. This framework helps in easy customization of your Bash shell.
If you need more help, please do reach our support department.