Bash Themes For Os X

Dec 11, 2006 And yes, this applies to all versions of OS X, as every version on every Mac defaults to using bash as the command prompt. OK let’s get started. The default command line prompt in Mac OS X is something like: ComputerName:CurrentDirectory User$ That would look something like this when the Terminal has been launched: MacBook:/Desktop Admin$. On OS X, user home directories are stored within a folder Users in the root, or top level, main directory, of your harddrive, represented by /. '/' means the main directory of your hard drive. Every file and folder on your computer lives somewhere inside of /. /Users is the main Users directory in OS X.

by rajaraodv

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.

Step 1 — Add A New Theme

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' > Terminal
  1. Go to http://ethanschoonover.com/solarized
  2. Scroll down and download the Theme (solarized.zip)
  3. Extract the solarized.zip file
  4. Open the osx-terminal.app-colors-solarized folder. This folder contains Theme for the terminal.
  5. Double click “Solarized Dark ansi.terminal”fileThis is the specific Theme file for Terminal.app. Note: If you get a warning that this is from an unidentified developer, Right-click on the file and select “Open with” > Terminal option.
  6. At this point, you have the Theme installed into your Terminal. We just need to make it a default Theme.
  7. Open Terminal > Preferences > Text and select the “Solarized Dark …” theme and click on “Default”.

From now on, your Terminal should like below.

Step 2 — Install Powerline

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.

2.1 Install Python

Because Powerline is a Python app, we need to have Python and that too a proper version of Python.

  • MacOS comes with Python installed already. Ensure Python’s version is 2.7.x by typing python -V in the Terminal.
  • If it’s not 2.7, install Homebrew that allows us to install various software from the CLI, by running:/usr/bin/ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'
  • Run brew install python to install the latest Python via Homebrew

2.2 Install pip — A package manager for Python (similar to npm)

Install pip by running the following command

$ sudo easy_install pip

2.3 Install XCode Developer CLI tools

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.

2.4 Install Powerline

Finally, install the Powerline (stable version) via pip by running the following command.

If you want to install the latest development branch, then use:

2.5 Add the Powerline daemon to bash

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

  1. Make sure you have .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 odd powerline-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.

Step 3 — Install Powerline 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.

3.1 Download the whole repo and unzip it

  • Click on the “Clone or download” button and download the whole repo so you try various fonts.
  • Unzip the fonts-master.zip

3.2 Install some fonts

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.

3.3 Select the font in the Terminal’s Theme

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!

  1. Open Terminal > Preferences > Text
  2. Select Solarized Dark ansi Theme
  3. Click on the “Font” button — This opens up “Fonts” dialog
  4. In the “Fonts” dialog, select “Meslo LG L DZ for Powerline” in the Family and also select font size 14 (so it’s easier to read).

3.4 Restart Terminal

Completely quit the Terminal (Terminal > Quit Terminal) and then reopen it.

Step 4 — Adding Git information to the prompt

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.

4.1 Install powerline-gitstatus

Note: “ — user” command is required to install it in the user’s profile.

4.2 Add powerline-gitstatus color schemes to Powerline

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): Ninjatrader for mac os x.

4.3 Activate The Theme

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.

4.4 Restart the Daemon

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.

4.5 Restart The Terminal

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

If this was useful, please click the clap ? button down below a few times to show your support! ⬇⬇⬇ ??

My Other Posts

ECMAScript 2015+

Terminal Improvements

WWW

Virtual DOM

React Performance

Functional Programming

WebPack

  1. Webpack & Hot Module Replacement [HMR] (under-the-hood)

Draft.js

React And Redux :

  1. A Guide For Building A React Redux CRUD App (3-page app)

If this was useful, please share it! Thank you! ??

Objectives

  1. Understand how to navigate your files using Terminal.
  2. Use pwd to identify the current directory of your Terminal session.
  3. Use ls to list the files in the current directory of your Terminal session.
  4. Use cd and cd . to change directories of your Terminal session.
  5. Use open . to open the current directory of your Terminal session in Finder.
  6. Use subl . to open the current directory in Sublime Text.

Overview

When you open a file on your computer, you locate it in by navigating through the directories on your computer's file system using Finder. Even files on your Desktop that you click on are stored in your computer's file system, your hard drive.

When you open an application from your Finder or Desktop, it always happens from the context of a 'Working Directory' - the directory of your computer you were in when you executed the program. When you click on a file on your Desktop or Open an application from Your Dock or Applications directory, you are still opening a file in a directory. The Dock and Desktop are just abstractions for that directory to make them easy to access.

For

We're used to navigating and operating on these files using our GUI, our Graphical User Interface, provided by OS X. Our Terminal provides us with a Command Line Interface to navigate and operate on the files and folders of our computer, just like the GUI. As programmers, the Terminal is our workbench, not the GUI.

Let's learn to navigate our computer using the Terminal Command Line Interface.

pwd and Working Directories

When you open a Terminal session, you are placed within a directory of your file system. Whatever programs execute or work you do in your Terminal, like when you click on things in your GUI, that action happens in the context of a 'Working Directory.'

A 'Working Directory' just means wherever on your computer's hard drive you are when you execute a program, again, whether through clicking on an icon in your GUI or running a command in your Terminal like learn hello. You did that from somewhere. We call that somewhere, wherever you currently are, a 'Working Directory'.

Open a Terminal and you'll be at your Command Line prompt, where your computer is waiting for instructions.

What's a Command Line Prompt

Our Command Line prompt, and maybe yours if you configured your environment through Learn, is represented by:

The first line, [16:19:43] ~ is telling us the current time, so expect that part to be different for you, and our current working directory, ~, which means our Home directory, the default directory for you. We'll explain that idea of a home directory or ~ in a moment.

The next line, // ♥ is our command line prompt, where we can type instructions and commands for our computer to execute. // ♥ is a customized prompt that you got by setting up your environment through Learn. To us the symbols // ♥ remind us of the way, '//', of love, '♥'. That's our mantra when we're programming. And we think it looks pretty cool given how much time we spend in our Terminal.

More generally, the command line prompt is represented by a $.

If you've read other tutorials, you might be familiar with seeing command line instructions with a $ to represent the prompt. We try to follow this convention in our instructions but you might sometimes see // ♥ in images or code samples.

What can you do from a command line prompt? Everything and anything. A command line prompt is the most powerful interface in the world, from which every computer and piece of software can be created, controlled, molded, manipulated, and used.

pwd - Print Working Directory

Let's run our second Command Line program (our first was when you ran learn hello).

Type pwd from your prompt. You should see something like:

From my home directory, ~, my Terminal presented me a prompt, $. I typed pwd and pressed Enter on my keyboard. My terminal responded with /Users/avi and returned me to my home directory, ~ and gave me a new prompt, $.

That's the standard procedure when you execute anything in Terminal, you enter a command from a prompt in a working directory, see output, and are returned to a new prompt in your working directory.

The pwd command is an acronym for 'Print Working Directory.' The pwd command prints the working directory of your Terminal session, the folder you are currently 'in.'

Knowing what directory you are working within is crucial when using your Terminal. You are opening files and running programs that live in directories and you need to make sure you're in the right directory for your task.

You never need to guess, if you're ever curious where you are or need to confirm you are where you think you are, type pwd.

~ - Your Home Directory

When you open a new Terminal session, you start in a default location in your file system called your Home Directory. When you use your computer, you are logged in under a user account, you're familiar with this as OS X asks you for your user's password occasionally.

Every user on your computer is given a 'Home Directory' for their files. Your operating system, OS X, uses this 'Home Directory' to keep your files private from other users that might share your computer.

On OS X, user home directories are stored within a folder Users in the root, or top level, main directory, of your harddrive, represented by /.

'/' means the main directory of your hard drive. Every file and folder on your computer lives somewhere inside of /.

/Users is the main Users directory in OS X. Within /Users, there is a folder for your username, the name of the account you use to login to your computer. My username is avi so my home directory is: /Users/avi. Yours will be different and you can see it by opening a new Terminal session and typing pwd.

The ~ (tilde) character is just a shortcut for your home directory, whatever it may be. Whenever you see your working directory or a file system path with a ~, you're home.

There's no place like ~.

ls - Listing Files in a Directory

Within a directory, one thing you're probably curious about is 'what files are in this directory?'. You can list files within your working directory by executing ls:

When we type ls in Terminal, we're asking our Terminal to list the files and folders in the current working directory.

In my home directory, ~ (which is really /Users/avi), I have 6 directories, Applications, Development, Desktop, Documents, Downloads, and Public. You probably have more.

Bash Themes For Os X 11

cd - Changing Directories

When you open a new Terminal session, you'll be in a working directory, probably your home directory, ~. But how do we move around to other directories and change our working directory? You can use the cd command, which stands for Change Directory.

From your home directory, try:

From within ~, our home directory, at our prompt $, we type cd Desktop. Our terminal will change the directory and enter our Desktop folder and our prompt will now indicate that our working directory is ~/Desktop. Your prompt might look a little different but you'll be in your Desktop directory. Confirm with: $ pwd (remember don't actually type $). pwd should output something like: /Users/avi/Desktop, the full path to your Desktop directory.

Once your working directory is your desktop, try ls and have your Terminal list any files that are on your desktop.

Bash Themes For Os X 10

. and .

How do you move from Desktop back up to your home directory? You can always move out of the current folder and back into the parent folder by typing cd .. Just like ~ is a shortcut for home directory, . is a shortcut that always means 'the directory above' or the 'parent directory' of the current. Your file system is a tree like structure, with directories being inside other directories:

Desktop is within avi which is within Users which is at the top of my hard drive, the root, /. The path to my desktop is: /Users/avi/Desktop. From within Desktop, you would refer to the parent directory, avi as ..

In the same manner that . means the directory above, the shortcut . means the current directory. You'll see why being able to refer to your current directory as . is helpful in a minute.

cd ~

You can also change directory back to your home directory from anywhere via cd ~. Remember that ~ is a shortcut that means home so if you type cd ~ you are telling your terminal to change the working directory to your home directory.

File or app crashes are something that a MacOS user is unintroduced with and this is something that makes this OS better than others.So on a comparative scale, online streaming with Mac OS can be a better option than others can!Is Kodi safe for Mac?Indeed! Applications in Mac do not crash as they do in other operating systems. Kodi for mac sierra. However, a Mac users does not worry about such issues as Mac is one of the safest operating systems to use.Another great thing about Mac which differentiates it from other operating systems like Windows and Android is the stability.

open - Opening Folders and Files

When you're in Terminal, sometimes it is useful to open the current directory you're in, your working directory, in Finder. You can do this with open .. That will pop open the OS X Finder view of the directory you are in.

subl - Opening Folders and Files in Sublime Text

Sometimes it's handy to be able to open a directory or a file right in your text editor. If you're using SublimeText, you can configure the shortcut subl to do just that!

To enable this shortcut, simply run

Now if you want to open an entire directory in Sublime Text, try subl .

atom — Opening Folders and Files in Atom

Bash Themes For Os X Download

Alternatively, is you're using Atom, you can select 'Install Shell Commands' from the menu under 'Atom' — this will install the atom shortcut for you, which works just like subl above — simply run

to open your current directory.

Hint: Tab Autocomplete

Bash Themes For Os X 8

When you're in Terminal, to autocomplete a directory or a command, start typing and then press TAB.

Resources

Bash Themes For Os X 7

View Navigating with BASH - OS X on Learn.co and start learning to code for free.