Terminal configuration with Bash-it / iTerm2

Configure and customize your bash-based shell with Bash-it to fit a more streamlined development workflow. Use bash-it plugins for more functionality and command line utilities.

In this article we explain how to customize the command line terminal, not only to adapt it to our tastes, but also to provide some features that can help you in the day-to-day development. You will see that there are many simple customization utilities, thanks to Bash-it, which may be liked by programmers in different technologies or system administrators.

I will explain how to carry out the steps focusing on Mac OSX, since it is the system where I have carried out this terminal customization process, although the software that we are going to use mainly, Bash-it, is available for multiple platforms such as Linux or Windows and the mode of Usage is generally the same, as read in the documentation.

Basically what we want to achieve is that, when you are using the terminal, it tells you what branch of the Git repository you are in, to save you from having to commit to a branch that you weren’t touching. We will also see that there are a series of extra plugins that can provide you with various types of help.

You can see in the following image how the terminal is displayed once customized with what we are going to explain in this article:

Before beginning, I want to mention that the list of configurations that we are going to install is offered by our friend and colleague Joan León, also a professor in various EscuelaIT courses.

Note to Mac OS X Catalina users

The framework described here, Bash-it, is geared towards Bash, which is the most common type of terminal. However, in OS X Catalina they have replaced Bash with Zsh. So if you want all these customizations to work you have to do a few extra things.

Once the Bash-it installation is run (process explained below) you would need to change the .bash_profile file and rename it to .zprofile. However, some important details would still not work.

The most definitive action would be to completely replace zsh with bash on your Mac with Catalina. There are numerous tutorials on the Internet that teach you the steps to achieve this.

iTerm2

On Mac, a good terminal alternative is iTerm2. It is a terminal very similar to the one that is installed by default in OS X, but it includes some improvements, such as working by tabs, having several terminals open in different panels, so that they can be seen at the same time, etc.

To install it, you simply have to enter: and follow the download and installation steps, as in any other application.

Settings in iTerm2

iTerm2 has the ability to install custom themes and fonts. We actually leave it up to you to experiment. However, there is a fundamental step for all this to work later, which is that you have the configuration of the Hack source.

You configure the font in “iTerm / Preferences / Profiles / Text” but it is important that you have your font configured in two headings:

In the following image you can see what we mean. But don’t worry if you don’t see the fonts we are going to install yet, because you will have to download them in a later step explained in this article.

Surely in your own terminal, in the system you are in, you have the possibility of configuring the source with other menus. But, for now, I insist that we are going to have to configure the sources a little later, since we have not downloaded them yet.

bash it

This is the main addition that we are going to explain. Just as iTerm is a Mac OSX-specific terminal, Bash-it is cross-platform. It basically offers you a set of additional commands, scripts and plugins to perform various tasks or customize the look and functionality of your terminal.

In the Bash-it repository you will find all the information on how to use this system. However, they are short on words, so we are going to explain the same things here, but in a little more detail.

Bash-it Installation

We start by installing the system, for which you have to clone the Bash-it repository.

This cloning can be done in various ways. If you know Git you won’t have any problems, but you can do it with a command like this:

git clone –depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it Note: You obviously need to have Git installed on your system. You can find more information on .com on how.

In the “clone” command above, you have the folder where Bash-it is to be installed in the last segment of the command, which would be “~/.bash_it”. That indicates that the repo is going to be cloned into your home folder and into the “.bash_it” directory. That directory is hidden on Linux and Mac systems, so you won’t see it from the file manager (Finder on Mac) and you can only access it via the command line. If you do not like that folder you can perfectly change it for another of your choice.

Once installed, we have to go to that folder and run the installation script. You can do it with “cd” to go to the folder where you installed it. Once in it you run the command:

./install.sh

You can save the “cd” command by specifying the path of the “install.sh” in the same command. If you installed the repo to “~/.bash_it”, then you can run this command to run the install script: “~/.bash_it/install.sh”.

Note that “install.sh” is the “bash” script for installing Bash-it. Once the installation is done you will have to restart the terminal for it to work. Please, do it before continuing with this tutorial to avoid problems.

Install a theme in Bash-it

To install a customization theme with Bash-it you have to edit a file called .bash_profile, where the name of the theme you want to put is indicated.

This file will be on your system. In my case it is in the root folder of my user, but I don’t know if in Windows or Linux it will be in another place.

The available themes are found in the “themes” folder of the Bash-it installation. In my case “~/.bash_it/themes”. You can choose any of them simply by name.

Edit the .bash_profile

To edit this file you can use your preferred editor. It is a text file, you can open it with a GUI editor like Atom, VSCode or Sublime, as well as a command line editor like “Nano” or “Vim”.

Personally, for these quick edits I usually use a command line editor that allows me to change the file without leaving the terminal. I’ll run the command “vim ~/.bash_profile”. But, if you don’t know Vim, it’s a bit tricky to explain here, so you can run the command “atom ~/.bash_profile”, which will open it for you with Atom (if you have it installed on your system).

Once the file is open, you have to look for the line that starts with “export BASH_IT_THEME” and edit the value to the theme you prefer, in my case it looks like this:

export BASH_IT_THEME=’Powerline-multiline’

The theme application may also force you to restart the terminal.

Install Bash-it plugins

Now we are going to install plugins that allow us to extend the functionality of the terminal. You have a bunch of plugins available in Bash-it, which you can list with the command:

bash-it show plugins

Now you can activate plugins you like with the “bash-it enable” command, followed by the plugin name. In my case I consider the Git plugin essential, which you would install like this:

bash-it enable plugin git

In your case you can install other plugins additionally. I also have some like “base, battery, node, javascript…”. Joan León gives a list of plugins that he uses in the repo that I mentioned at the beginning of the article.

To see the help of the installed plugins you can type this command:

bash-it help plugins

It will show you the help of all the plugins that you have activated. If you see that one doesn’t interest you and you want to remove it, simply run the command “bash-it disable plugin”

bash-it disable plugin git

Install Bash-it Aliases

Among the many things that Bash-it offers and that you will get to know, there are some interesting aliases for a multitude of technologies.

For example, there is one that is “ll”, which is equivalent to “ls -la” and that is very convenient to use. If I’m not mistaken, this alias is available as soon as you install it, in the “general aliases” classification, so you can use it simply by installing Bash-it.

In any case, we explain how to install aliases of your choice. The first step is to know what aliases are available, with:

bash-it show aliases

You can enable any of the aliases in the list with the command: “bash-it enable aliases” followed by the name of the alias to include. For example:

bash-it enable alias git

Install fonts for Bash-it

Finally, another step that we had said that you will have to do is provide yourself with sources designed to be used in the terminal. This step is important because some plugins use them and for them to display well you need a certain set of fonts.

The fonts we are going to install are available in another GitHub repository https://github.com/powerline/fonts

To install it you have to clone and run the “install.sh” script, which you will do in a similar way to the process commented above to install Bash-it.

git clone https://github.com/powerline/fonts.git –depth=1

That will create the clone for you in a folder called “fonts”, which will have been placed as a subdirectory of the directory you were in when you ran the command. You will have to get into that folder with:

cd fonts

Then you install the fonts by running the “install.sh” file, with the command:

./install.sh

Finally, you can delete the “fonts” directory with the newly cloned repository, because once the fonts are installed, that folder is no longer needed at all.

Remember that these fonts are installed on your operating system. You could follow other steps to install the fonts if you prefer, which may depend on the system you’re using. For example, this can be useful if the installation with install.sh has not worked well in your case, or if you do not want all the sources included in this repository to be installed. In the repo folders you will find one for each font that will be installed.

Now all you have to do is assign the font you want in your terminal program. In my case I have configured a “Hack” call.

Note: Please note that for iTerm2 users, you need to install the font and non-ascii font, as explained earlier in this article.

Conclusion on installing and configuring Bash-it

Remember that after these steps you have to restart the terminal for the changes to be seen. Surely throughout the process you have had to do it several times.

Now the command line terminal will look in a different way, which you can customize according to your tastes,…

See also  Rectangles with rounded corners on canvas, interactive with Mootools
Loading Facebook Comments ...
Loading Disqus Comments ...