Customizing Your Terminal

The command line is in wide use today. Unlike days past though, we have greater ability to customize our experience. We don’t need to settle for green or amber text on a black background. We can be more creative, if we choose. On Mac, we have multiple applications – Terminal, iTerm – to provide access to the command line. The placement of the settings in your application will change, but the concepts are universal. For the rest of the article, iTerm will be used to refer to your application, and terminal is interchangeable with command line.

The main thing people do to customize iTerm is setting the foreground and background colors. This provided the default values that your terminal uses to display the interface. There are multiple factors though that can affect the display – Some of which are LSCOLORS, prompt colors, and your vim theme.

LS Colors

The ls command is one of the most commonly used in the terminal. So how it’s output is displayed is going to affect your user experience on the command line. The ls command has an option to display the colorized output. The ls command uses a simple syntax to control the output

-F display file types: show / character at end of directory names

-G colorize the output of different file types

As you can see the ls -G command outputs with the colors turned on. If you’d like the output to always be enabled, you can create an alias

alias ls=”ls -G”

To customize the colors, you’ll need to create a variable called LSCOLORS, that has 17 values total that can be used – 8 regular colors, 8 bold version of those colors, and the default colors. You’ll need to read the man page on your system for details.

Prompt Colors

Bash provides the ability to use escape sequences to set colors, both foreground and background, with the prompt variables. While these escape codes aren’t very intuitive to work with, they do give you control over where in the prompt the colors change. In addition to using color, these escape codes give you the ability to do bold colors, reverse, underline, and god forbid blinking text.

Bash provides four levels of prompt. The primary prompt is controlled by the PS1 variable. This is the one that you’ll use most often – so you can skip the others, if you want. However the terminals escape sequences should work on all the prompt variables.

When you set the PS1 variable, it is determined by your .bashrc or .bash_profile, and not the iTerm application. The colors you use in the variables may conflict with the colors set in iTerm application. So you’ll need to use caution when choosing your colors. The iTerm application sets an environment variable for your convenience, that contains your profile name, when the tab or window is created. Using this, in conjunction with bash scripting, allows you programmatically determine which profile is in use, so you can set your values accordingly.

  • PS1
  • PS2
  • PS3
  • PS4

Vim Theme

The system used by Vim is different than the escape codes used by bash, and the LSCOLORS variable. Vim seems to override the terminal colors. As a result, you can’t rely on natural compatibility between the color schemes. Most people have a light theme and a dark theme for general use. However, depending upon the colors you select, some combinations won’t work well. To ensure maximum compatibility, spend some time creating a theme designed to match the color scheme of your iTerm application.

The process of creating a theme, or color scheme in Vim parlance, can’t be explained in a paragraph. You’ll need to read some tutorials. To simplify the process though, you should start with an existing theme to get you close, then tweak as needed. Not only will that save you a lot of work, but you’ll learn a lot by reading other people’s code.


Before you starting messing with your terminal, I’d recommend doing some research first – particularly if you don’t have a good design sense. A good way to do that is by looking at examples of existing themes. you can start by looking at the themes Vim already uses. Also, open up other editors that you use – Sublime, TextMate, Atom, et cetera. Do you prefer dark themes or light themes? I prefer dark themes. I find them to be less intense – particularly at night. As you look through the themes, reflect on the following questions:

  • Do I want to create a light theme or dark theme?
  • Are the colors accessible?
  • What do i like about this theme?
  • What do i dislike about this theme?
  • Is this theme close to what I want?

When creating your themes, keep accessibility on your mind – particularly contrast. Contrast is the difference between two values. Low contrast is light gray on white – which is a mistake you see often on websites. Try to avoid bright white on pitch black. If that’s your starting point, it can feel harsh. Also, when you make something bold, it won’t stand out, because you started at the highest value. The opposite combination – pitch black on bright white – is even more severe. It has the same problem, but also has an additional problem. The bright white background will make your eyes tired faster. Not the idea user experience! light grey on black or black on soft white or light beige would be a better starting point to soften the contrast a little.

The strategy you employ will depend primarily on your desired palette and your objective. However, they will all require the same initial steps.

In your iTerm application, Create a profile so you can:

  • Name your profile
  • Set foreground and background colors
  • Set your cursor type: underline, vertical bar, or box.
  • Set your font

Part of the fun will be experimenting with colors and fonts. OK, that’s most of the fun. If you’re developing a theme for coding, you’ll want to stick with monospace (fixed-width) fonts. For other types of writing, experiment with serif and sans-serif fonts. I’d suggest delay experimenting with other font types until you’re more comfortable with command line theming.

Maximum Compatibility

If you want something that’ll work everywhere, start with the common functionality and colors.

The simplest color palette are in the LSCOLORS for the ls commands. use the default terminal colors for most of the file types the. Then choose bold colors for your directory

and symlinks options. Then use reverse the default colors for special items that you wan to pay attention to e.g. setuid files.

App Inspired

Do you have a favorite that you use today, or from days gone by? Try emulating that app with your theme. It won’t be perfect, but you can create an homage to it.

When I was writing papers in university, WordPerfect was my favorite word processor. Fortunately the computers in the CSULB library had WordPerfect. WordPerfect was famous for it’s white text on medium blue background. It also had this mode called “Reveal Codes” which exposed the formatting so you could debug any issues. Man, that was awesome. Anyway, if memory serves, it would show errors as red text on a light gray background.

Retro / Monochrome

This is similar to the Maximum Compatibility strategy, with the added constraint of using a single color. Most people I grew up with had green text on black for their monitors. My 386 PC in college had an amber text on black monochrome monitor. Linux systems default to white/black before booting to XWindows.

Role Specific

Initially, i was thinking of a role-based theme, would make sense for root. So when ever you looked at that terminal, it would be clear that you had elevated privileges. A # for your prompt doesn’t seem like enough. i know iTerm will let you change the theme if you’re in a different directory or a particular username matches. It’s also true that role could refer to the type of work you’re doing. Coder is a role, just as author or editor is a role. It could be called writer or blogger or editor.


Try pushing the limits of theming capabilities. Make the most of your particular application. I use iTerm2. I love this application, because it has a couple of cool features. It has support for transparent colors. For example, using transparency for a selection background, is a great use case. It allows for subtler combinations of colors. Using a transparency for your window background can create an interesting user experience. It allows you to see the content behind your terminal window. If you’re watching a video while your working the terminal, you can do both. Perhaps you’re taking notes about the video. You don’t have to worry about your terminal covering your other content.


Between the iTerm, bash, and vim, you can create a consistent theme experience. In a bashrc file, things can get disorganized if you don’t focus on keeping things organized. I suggest creating a bash function that represents your theme, to set the values associated with it. For example let’s say that in my application, I created a profile called ‘WordPerfect’. In my ~/.bashrc, there would be a function called ‘wordperfect_settings’, that should set the value of PS1 and LSCOLORS, and set a vim alias to load your desired theme. Assuming your theme name matches your iTerm profile name, ‘WordPerfect’ in my case, you can create an alias to use your desired theme. Naturally you’ll need to create your vim theme and install it, but it’s as easy as creating an alias like so.

alias vi=”vi -c ‘colo wordperfect'”

Sorry, but comments are closed. I hope you enjoyed the article