Tuesday, July 14, 2015

Set your prompt with git branching information

parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'

function remoteBranch() {
    git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null | sed 's/origin\///'

PS1="\[\e[01;31m\]\$(parse_git_branch)\[\e[00m\]:\$(remoteBranch) \w:\n\[\e[01;31m\]$ \[\e[00m\]"

Very helpful to when you are juggling several beasts at the same day

Set the git repo name on terminal Title

function get_repo_name() {
if git rev-parse — git-dir > /dev/null 2>&1; then
 basename `git rev-parse — show-toplevel` 2>&1 /dev/null

PROMPT_COMMAND=’echo -ne “\033]0;$(get_repo_name)\007”’
Very helpful when having many tabs open on while developing cool shit!