Skip to content

Instantly share code, notes, and snippets.

@evansde77
Last active March 20, 2019 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansde77/9b24b87f07f53dfcc69fedbdd1dc970a to your computer and use it in GitHub Desktop.
Save evansde77/9b24b87f07f53dfcc69fedbdd1dc970a to your computer and use it in GitHub Desktop.
Example bash command to show current branch in shell prompt that can be added to bashrc/bash_profile
function parse_git_branch ()
{
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
BRANCH="("${ref#refs/heads/}")";
echo "${BRANCH}"
}
export PS1="[\t \W] \$(parse_git_branch) "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment