Skip to content

Instantly share code, notes, and snippets.

@lbland94
Last active July 10, 2020 14:55
Show Gist options
  • Select an option

  • Save lbland94/fbe6eef6a3a317044c67e289ad4c7c78 to your computer and use it in GitHub Desktop.

Select an option

Save lbland94/fbe6eef6a3a317044c67e289ad4c7c78 to your computer and use it in GitHub Desktop.
Git OSX Setup Steps

Git OSX Setup Steps

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Create a ~/.gitexcludes file and paste in this:

.DS_Store

Bash stuff

Add the following to your ~/.bashrc:

# Prompt customization
parse_git_branch() {
  git=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/')
  trimmed=${git: 0: 30}
  trimmed=${trimmed:-$git}
  echo "$trimmed"
}

get_trimmed_path() {
  path=$(echo $PWD | sed "s:$HOME:~:g")
  trimmed=${path: -40}
  trimmed=${trimmed:-$path}
  echo $trimmed
}

export PS1="\[\033[96m\]\u:\[\033[1;33m\] \$(get_trimmed_path)\[\033[0;94m\]\$(parse_git_branch)\[\033[00m\] $ "

# Git (and other) autocompletion
if [ -f /usr/local/share/bash-completion/bash_completion ]; then
  . /usr/local/share/bash-completion/bash_completion
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment