Created
November 8, 2008 05:32
-
-
Save chris/23031 to your computer and use it in GitHub Desktop.
zsh Git branch in your 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
# zsh Git branch in your prompt, etc. | |
function precmd() { | |
# define colors | |
local RED="%{[1;31m%}" | |
local LIGHT_RED="%{[0;31m%}" | |
local CYAN="%{[1;36m%}" | |
local LIGHT_CYAN="%{[0;36m%}" | |
local BLUE="%{[1;34m%}" | |
local LIGHT_BLUE="%{[0;34m%}" | |
local GREEN="%{[1;32m%}" | |
local LIGHT_GREEN="%{[0;32m%}" | |
local MAGENTA="%{[1;35m%}" | |
local LIGHT_MAGENTA="%{[0;35m%}" | |
local YELLOW="%{[1;33m%}" | |
local LIGHT_YELLOW="%{[0;33m%}" | |
local GRAY="%{[1;30m%}" | |
local LIGHT_GRAY="%{[0;37m%}" | |
local ORANGE="%{[1;43m%}" | |
local WHITE="%{[1;37m%}" | |
local NO_COLOUR="%{[0m%}" | |
git_prompt_info() { | |
ref=$(git-symbolic-ref HEAD 2> /dev/null) || return | |
echo "${ref#refs/heads/}" | |
} | |
# set the prompt (login cwd git-branch) | |
PS1="$GRAY%n@%m$NO_COLOUR $LIGHT_YELLOW%~$NO_COLOUR $GREEN$(git_prompt_info)$NO_COLOUR | |
$ " | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment