Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Last active February 26, 2024 10:36
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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