Created
July 23, 2015 01:00
-
-
Save irlevesque/9362ad78dfe1e7c7a352 to your computer and use it in GitHub Desktop.
Git prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If we're in a git repo, print the first 9 characters of the current committish. | |
function parse_git_commit() { | |
git rev-parse HEAD 2>/dev/null | cut -c1-10 | |
} | |
# If we're in a git repo, print the current branch name. The sed call deletes | |
# any line not starting with '* ', then removes the '* ' | |
function parse_git_branch () { | |
git rev-parse --abbrev-ref HEAD 2>/dev/null | |
} | |
# If we're in a git repo, print "@(<branchname>:<committish>)" | |
function current_git_info (){ | |
branch=`parse_git_branch` | |
commit=`parse_git_commit` | |
# If branch is not empty | |
if [ ! -z "$branch" ] | |
then | |
echo "@($branch:$commit)"; | |
fi | |
} | |
PS1='$(current_git_info) \[\e[0;32m\][\u@\h]\[\e[m\] \[\e[1m\][\t] \[\e[1;34m\][\w]\[\e[m\]\n \$ \[\e[m\]' |
Author
irlevesque
commented
Jul 23, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment