Skip to content

Instantly share code, notes, and snippets.

@heiglandreas
Created June 16, 2016 16:24
Show Gist options
  • Save heiglandreas/4b7b84f10b5a3468efb9f448753b0a73 to your computer and use it in GitHub Desktop.
Save heiglandreas/4b7b84f10b5a3468efb9f448753b0a73 to your computer and use it in GitHub Desktop.
# Get the current GIT-Branch-name in brackets
function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
# Set the current IP-Address to the variable IP
IP=$(route -n get default|grep interface|cut -b 14- | xargs ipconfig getifaddr);
#
# Set the Prompt to the following:
# username@ip-address currentDirectory gitBranchIfExists
export PS1="\u@\[\033[1;31m\]$IP\[\033[0m\] \W\[\033[33m\]\$(parse_git_branch_and_add_brackets)\[\033[0m\] \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment