Skip to content

Instantly share code, notes, and snippets.

@AtmaMani
Last active February 26, 2025 12:29
Show Gist options
  • Save AtmaMani/7e4be79a4a8434208cccfaea9018601d to your computer and use it in GitHub Desktop.
Save AtmaMani/7e4be79a4a8434208cccfaea9018601d to your computer and use it in GitHub Desktop.
Mac Terminal colors

Get your mac terminal to utilize full color palette

Steps:

1. Edit bash_profile

The color profile of your terminal is stored in .barsh_profile in your home directory. Lets edit that in your terminal:

$ cd ~
$ nano .bash_profile

or if you have sublime text installed using homebrew then:

$ subl ~/.bash_profile

Note: you may have to prefix sudo before the nano command. Once the nano text editor opens, paste the following

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'

Follow the key sequence at the bottom of nano to save and quit (Ctrl + O and Ctrl + X). With this, you should see some basic coloring for your name prompt and commands like ls. Reopen terminal for this to take effect.

2. Modify terminal prompt display information

Your prompt by default displays the username, and the file path. However if you are the only person using it, then some of this is redundant and takes up space when your work on long paths. To change this and to decorate the prompt with GIT branch names and local status, append the following to the same ~/.bash_profile. Credit this codementor.io article

# colors
PS1='\w\[\033[0;32m\]$( git branch 2> /dev/null | cut -f2 -d\* -s | sed "s/^ / [/" | sed "s/$/]/" )\[\033[0m\] \$ '

# Tell grep to highlight matches
export GREP_OPTIONS='--color=auto'

# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad

3. Customize in preferences

You can customize terminal further through preferences dialog. To open, use shortcut cmd + k.

In the profiles tab, click on a theme. Ensure the checkboxes under Text section are enabled. You can try out the opacity, text color combinations to suit your preferences.

3. Tab autocomplete

Improve the tab autocomplete so it suggests no matter the case and even if there are ambiguous results. Help link Open

subl ~/.inputrc

then type the following and save

set completion-ignore-case on
set show-all-if-ambiguous on
TAB: menu-complete

3.1 Tab autocomplete for GIT

Enhance the autocomplete to list GIT branch names, GIT commands as well by appending the following to the ~/.bash_profile. Credit this repo

$ brew install bash-completion

Then follow the instructions at the end to add the string to your bash_profile. Restart terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment