Setting up the Bash Shell on OS X

Author: MikeW    Date: 2016-08-21 12:25   

One the first things I do with a Unix based system is setup the Bash shell. You can make your shell a lot more colorful and useful with just a few changes.

Configure Startup Files

The first thing to do is setup the bash configuration files so that your configuration gets loaded everytime. When a shell starts, it will load the settings in your .profile file or your .bash_profile file. However, any new shell uses the .bashrc file to load settings. So to keep all my settings in one file, this is what I do.

First, but this into your .bash_profile file.

. .bashrc

This calls the .bashrc file and loads its contents into the shell during initial load. This line allows you to put all your configuration in the .bashrc file. Thus, all edits take place in one file.

Setup Aliases

Next, I make some edits to the .bashrc file to make my life easier.

The OS X bash allows you to colorize all the output from the ls command to do this add the following to .bashrc.

# Aliases
alias ls='ls -G'
alias ll='ls -lG

This returns a colorized version of all data from the command. Thus, it is much easier to distinguish between directories and files, etc...

Setup the Path

Next, I like to setup my shell prompt to show the path using the PS1 environment variable. I also setup an export command for the PATH environment variable. Add the following lines to the .bashrc file.

export PS1='\h:\w \$'
export PATH=$PATH:

That covers the basics.