Created
November 29, 2012 17:06
-
-
Save thanosa75/4170427 to your computer and use it in GitHub Desktop.
Colored prompt with git support
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
# add this snippet in your .bashrc and enjoy a green foreground color, | |
# with HH:MM time info, plus directory and git data on a directory that | |
# has git information (git repo) | |
# | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
# parse and create the prompt | |
function parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
lastcommit=$(git log -1|head -1|awk '{print $2}'|colrm 8) | |
echo "("${ref#refs/heads/}-$lastcommit")" | |
} | |
# colors!!! | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
# set the prompt | |
PS1="$RED\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$GREEN\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample prompt at http://s9.postimage.org/sj2j6qnpr/sample.png