Installing Bash

If you do not have Bash installed you can use HomeBrew to install the shell package.

$ brew install bash-completion

Using the CLI type ls -a which is the command to list all files including dot and hidden files in your computer if you have a .bash_profile type open .bash_profile if you do not

open .bash_profile - if you do not have a .bash_profile

and copy and paste this code into the file

[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion

Close the file and restart your session

The .bashrc file

To customise your Bash shell you will need a .bashrc file, if you do not have one create it by running touch .bashrc in your terminal

Once you’ve done this, you can use Bash completion by pressing the tab key twice after a command. Bash completion is a Bash function that allows you to auto complete commands or arguments by typing partially commands or arguments, then pressing the [Tab] key.

For example:

$ git [tab] [tab]
mergetool      range-diff     replace        send-email     stash          worktree
apply          bundle         clean          diff           gc             init           mv             rebase         request-pull   shortlog       status
archive        checkout

We use some commands so frequently that it’s often helpful to setup an alias for them. You can do this with this command: alias shortcut=long command

Some potentially useful aliases:

# List directory contents
alias ll="ls -lh"

# Current git status
alias gs="git status"

# Undo all local changes - use with caution!
alias grh="git reset --hard"

# Change directory to the cloud project
alias cloud="cd $HOME/projects/in2plane-cloud"

# Change directory to the API V2 project
alias api="cd $HOME/projects/in2plane-api"

Prettify your git logs

You can configure the terminal to include a colourful prompt showing the current git branch next to the cursor.

Add the following to your ~/.bash_profile and restart the session:

export CLICOLOR=1
source /usr/local/git/contrib/completion/git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=true
reset=$(tput sgr0)
export PS1='\w \[\033[01;32m\]$(__git_ps1)\[$reset\] \$ '

Further reading and to debug your .zshrc file if you get errors: