Mac Terminal Colors for Command Prompt

January 23, 2013 — Leave a comment

Purpose: To help distinguish between commands and command output.

Example: See below. You may choose a different set of element colors.

Video: See bottom of this post.

Note: My current Terminal – Preferences are set to {Theme: Basic, Font: Menlo, Font Color: Yellow, Font Size: 16}

Example:

wpid277-Example.png

Prerequisite: Configure colors for ls command

Follow these instructions to edit your .profile file.

 

1. Open .profile File

Execute these commands:

$ cd ~
$ open .profile

2. Edit .profile

wpid276-2._Edit_.profile.png

Add the following line to the .profile file or see step 4 for customization help:

PS1="\[\e[0;36m\]\h\[\e[m\].\[\e[0;36m\]\u\[\e[m\].\[\e[0;36m\]\W\[\e[m\].\[\e[0;32m\]$ \[\e[m\]"

3. Save and Re-open Terminal

Save .profile and open a new Terminal window.

4. Customize

Here’s a helpful resource for learning more about possible customizations to your bash command prompt.


Video:

.profile content from video:

# ------------Color Aliases ---------------
BLACK="0;30"
GREEN="0;32"
CYAN="0;36"
RED="0;31"
PURPLE="0;35"
BROWN="0;33"
BLUE="0;34"

LITEGREEN="1;32"
LITECYAN="1;36"
LITERED="1;31"
LITEPURPLE="1;35"
LITEBROWN="1;33"
LITEBLUE="1;34"
#-------------End Color Aliases------------

PS1="\[\e[\$CYAN m\]\h\[\e[m\].\[\e[\$CYAN m\]\u\[\e[m\].\[\e[\$CYAN m\]\W\[\e[m\].\[\e[\$GREEN m\]$ \[\e[m\]"

#DEFAULTPROMPT="\\u@\h \\W\\$ "

#PROMPT="\h.\u.\W.$ "

#PS1="\[\e[\$PURPLE m\]$PROMPT \[\e[m\]"

Jay

Posts

No Comments

Be the first to start the conversation.

I welcome your comments