Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Last active September 23, 2024 13:29
Show Gist options
  • Save alexpaul/8ac787daabd8118d5ec5a14f39b7bcf8 to your computer and use it in GitHub Desktop.
Save alexpaul/8ac787daabd8118d5ec5a14f39b7bcf8 to your computer and use it in GitHub Desktop.
Creating a Bash Profile

Bash

What is a bash_profile

There is a hidden file in your Mac’s user directory named .bash_profile. This file is loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command line interface. Within it you can change your terminal prompt, change the colors of text, add aliases to functions you use all the time, and so much more.

Creating a .bash_profile

If you run the open ~/.bash_profile command and do not have a current .bash_profile, follow these steps to create one:

  1. Open Terminal
  2. Navigate to your home directory cd ~/
  3. Create the file touch .bash_profile
  4. Now you can use open ~/.bash_profile to edit your .bash_profile

Using your existing .bash_profile

open ~/.bash_profile 

save your updated profile

source ~/.bash_profile 

Verify what shell you are using echo $SHELL

Some output examples will be:

  • /bin/csh
  • /bin/bash
  • /bin/ksh

Common Unix Shells

Shell Name Summary
sh original Unix shell, often call the Bourne Shell, great for scripting but lacks flexiblity and power for interactive use, doesn't have features like command completion, email checking, history, or aliasing
csh and tcsh often called the C shell for its syntax style, great for C programmers
ksh, bash and zch good blend of scripting and interactive capabilities, bash is most similar to sh, hence the Bourne Again SHell name
Resource Summary
UNIX - Visual Quickstart Guide By Deborah S. Ray, Eric J. Ray
About bash_profile About bash_profile
Add Git Branch Name to Terminal Prompt Add Git Branch Name to Terminal Prompt

add git branch name to terminal prompt

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