by rajaraodv
Open Terminal and enter git -version. If you see git version followed by numbers, i.e., git 2.5.4 then you are good to go. Click on Mac OS X below Downloads. Open the git-2.8.1-intel. ITerm2 3.4.0beta7 (OS 10.14+) This is the recommended beta build for most users. Show Changelog Hide Changelog 3.4.0beta7 New Features - Add Snippets and Actions to a new Shortcuts tab in prefs, and ways to access them in various places throughout the app, including new status bar components. Nov 30, 2018.
In this blog I’ll go over the steps to add Themes, Powerline, fonts, and powerline-gitstatus to make your regular Bash Terminal look beautiful and useful as shown in the picture above.
It turns out, if you are using Mac, you’ll need to jump through a lot of hoops to get this working as many instructions are for linux, or are out of date. So I thought I'd blog about it - hopefully it'll help you.
Notes:
1. Follow the steps carefully as any mistake will cause a lot of headaches.
2. This is for MacOS and for regular bash in the Terminal.app. I’m not using ZSH or Hyper in this blog — I plan to write different blogs for them.
3. My Versions: Mac High Sierra; git version 2.14.3 (Apple Git-98); Python 2.7.10
OK, by default, when you have a new mac, your Terminal.app will look something like below. Let’s go ahead and add Themes, fonts, and so on.
The first obvious step is to enhance the Theme. Terminal doesn’t provide all the cool and fancy themes that you see other developers use. Let’s download a Theme and add it to the Terminal.
In this blog, I’ll add Solarized-Dark theme to our Terminal.
Note: You can download various Themes (.terminal files) from this git repo. Simply open the*.terminal
file to install it, i.e.right-click on the *.terminal file > “open with' > Te
rminal
From now on, your Terminal should like below.
Powerline is a Python app and is a status line plugin for vim, and provides status lines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome and Qtile.
It makes the Terminal prompt look like below.
Because Powerline is a Python app, we need to have Python and that too a proper version of Python.
python -V
in the Terminal./usr/bin/ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'
brew install python
to install the latest Python via HomebrewInstall pip by running the following command
$ sudo easy_install pip
XCode Developer CLI tools are used by Powerline and other apps that manipulate core OSX features. So make sure to install the XCode CLI tools by running the following command.
$ xcode-select —-install
Note: The above command opens up Mac’s installer and installs the XCode Developer CLI tools. If it doesn’t work, try xcode-select -r
to reset.
Finally, install the Powerline (stable version) via pip by running the following command.
If you want to install the latest development branch, then use:
We now need to add the Powerline daemon to bash so that it can monitor the Terminal prompt and make changes.
2.5.1 Copy the Powerline’s installation location
You can figure out the location of Powerline by running the following: pip show powerline-status
Copy the value from the Location
field.
2.5.2 Add the daemon with a proper location to .bash_profile
.bash_profile
file in your root directory. If not following create one by doing: cd ~ && touch ~/.bash_profile
2. Open .bash_profile
and add the following:
Note: The location /Users/rupa/Library/Python/2.7/lib/python/site-packages/ is from the previous step (2.5.1). Change it to match your computer’s location.
2.5.3. Restart the Terminal
Completely quit the Terminal if it’s open (Terminal > Quit Terminal). And open it again.
You should be able to simply use$ source ~/.bash_profile
to update the settings. But I got some oddpowerline-config
file is missing! Typically you get this error if you don’t have $HOME/Library/Python/2.7/bin in your PATH.
2.5.4 Your new Terminal
Your new Terminal should look like below. It should be using “Solarized Dark ansi” theme and should show Powerline in the command prompt. But also notice that there are “?” characters! This is because Powerline uses various icons and fonts that are not available by default. So we need to install the fonts.
To install Powerline fonts, simply go to https://github.com/powerline/fonts. There you’ll see a whole bunch of folders. Each one is a font, aka “Patched fonts”.
It is called “Patched fonts” because people have taken regular fonts and have added/patched additional Powerline specific icons and fonts to them.
Let’s open Meslo dotted fontsfolder. It will look like below. You’ll see a whole bunch of .ttf file. Each one of them is a font but some are “bold” version of the font, some are “regular” version and so on.
Simply double-click on the .ttf file and press “Install font” to install the font on your computer.
For our case, let’s install “Meslo LG L DZ Regular for Powerline.ttf” and “Meslo LG L DZ Italic for Powerline.ttf”. This will add a regular and an Italic version of the Meslo font.
Remember we added “Solarized Dark” theme in Step 1? That didn’t have any fonts in it and MacOS had some default font. All we need to do is to set our Meslo dotted font for this theme and we are done!
Completely quit the Terminal (Terminal > Quit Terminal) and then reopen it.
In order to display various Git status at the prompt, we need to install powerline-gitstatus. It is a simple add-on to Powerline and adds multiple colors and Themes to display various git status information.
Note: “ — user” command is required to install it in the user’s profile.
4.2.1 Open the following colorschemes/shell/default.json
folder
4.2.2 Add the following colors:
As mentioned in the powerline-gitstatus readme. PS: Just copy the colors inside “groups” and then append it to the default.json as shown below.
Here is my color schemes default.json (you may copy and paste this instead):
4.3.1 Open Theme’s default.json file
4.3.2 Add the following to the default.json
Below is my Powerline’s Theme default.json(you may copy and paste this instead):
Note: I have removed everything from the “right” section and also removed “job number” (“jobnum”) to keep things clean. Otherwise, you’ll see a little artifact on the right-hand side edge of the prompt.
Save the file and run the following: powerline-daemon —-replace
in the Terminal.
Important Note: Every time you make changes to Powerline’s config, in addition to restarting the Terminal, you’ll also need to restartthe daemon to see the changes reflected by running: powerline-daemon —-replace
.
Quit the Terminal (Terminal > Quit Terminal) and open it again.
At this point, we are all done! whew! If you open the Terminal, and navigate to any git repo, and play around, it should look like the following.
Here is how it looks in Solarized-Light Theme:
Here is how it looks in Cobalt2 Theme:
?? Thank you!
If you have questions, please feel free to ask me on Twitter: https://twitter.com/rajaraodv
How to install Git on any OS
Git can be installed on the most common operating systems like Windows, Mac, and Linux. In fact, Git comes installed by default on most Mac and Linux machines!
To see if you already have Git installed, open up your terminal application.
Once you've opened your terminal application, type git version
. The output will either tell you which version of Git is installed, or it will alert you that git
is an unknown command. If it's an unknown command, read further and find out how to install Git.
Installing GitHub Desktop will also install the latest version of Git if you don't already have it. With GitHub Desktop, you get a command line version of Git with a robust GUI. Regardless of if you have Git installed or not, GitHub Desktop offers a simple collaboration tool for Git. You can learn more here.
git version
to verify Git was installed.Note: git-scm
is a popular and recommended resource for downloading Git for Windows. The advantage of downloading Git from git-scm
is that your download automatically starts with the latest version of Git included with the recommended command prompt, Git Bash
. The download source is the same Git for Windows installer as referenced in the steps above.
Most versions of MacOS will already have Git
installed, and you can activate it through the terminal with git version
. However, if you don't have Git installed for whatever reason, you can install the latest version of Git using one of several popular methods as listed below:
git version
to verify Git was installed.Note: git-scm
is a popular and recommended resource for downloading Git on a Mac. The advantage of downloading Git from git-scm
is that your download automatically starts with the latest version of Git. The download source is the same macOS Git Installer as referenced in the steps above.
Homebrew is a popular package manager for macOS. If you already have Homwbrew installed, you can follow the below steps to install Git:
brew install git
.git version
.Fun fact: Git was originally developed to version the Linux operating system! So, it only makes sense that it is easy to configure to run on Linux.
You can install Git
on Linux through the package management tool that comes with your distribution.
apt
.sudo apt-get update
.sudo apt-get install git-all
.git version
.dnf
.sudo dnf install git-all
.git version
.Note: You can download the proper Git versions and read more about how to install on specific Linux systems, like installing Git on Ubuntu or Fedora, in git-scm's documentation.
Looking to install Git via the source code? Learn more here.
Contribute to this article on GitHub.
Review code, manage projects, and build software alongside 40 million developers.