Skip to content

Instantly share code, notes, and snippets.

@WagnerMoreira
Last active March 29, 2021 16:55
Show Gist options
  • Save WagnerMoreira/8ad2d9747bb7473465387766dbc3e697 to your computer and use it in GitHub Desktop.
Save WagnerMoreira/8ad2d9747bb7473465387766dbc3e697 to your computer and use it in GitHub Desktop.
Github setup

Global configuration

git config --global user.name 'your_github_username'
git config --global user.email 'your_github_email'

Shortcuts

(Run the command below in your terminal to open the config file using VScode)

code ~/.gitconfig

#paste this, if there are more settings there you don't need to remove them, just add the following sections

[alias]
  st = status
  ci = commit
  co = checkout
  br = branch
[color]
  branch = auto
  diff = auto
  interactive = auto
  status = auto
  ui = true
[color "status"]
  added = yellow
  changed = cyan
  untracked = red

Git Branch Config

code ~/.bash_profile

paste

function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}

export PS1='\[\e[1;37m\]\w\[\e[m\] $(parse_git_branch "(%s)" ) \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\]'

This command will make your terminal refresh its configs and make the above ^ configs effective, if this for some reason does not work, just open and close your terminal again or do cd . which should also work as it will be trying to access the same folder that you are located right now and refresh the configs.

source ~/.bash_profile

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