Permalink
Browse files

Make prompt show git branch on another line.

  • Loading branch information...
jlatt committed May 19, 2012
1 parent 082099d commit 931ede52a3c984d51ed8a12d66f01b2726c918df
Showing with 4 additions and 3 deletions.
  1. +4 −3 prompt.sh
View
@@ -5,17 +5,18 @@ set -a
function maybe_git_branch() {
branch_name="$(git branch-name)"
- if [[ "$?" -eq 0 ]]; then
+ if [[ "$branch_name" ]]; then
branch_name="${YELLOW}git${NORMAL}:${AQUA}${branch_name}${NORMAL}"
upstream_branch="$(git upstream-branch)"
if [[ "$upstream_branch" ]]; then
branch_name="${branch_name} <-> ${AQUA}${upstream_branch}${NORMAL}"
fi
- echo -ne " [${branch_name}]"
+ echo -e "[${branch_name}]"
+ echo -e "\r"
fi
}
-PS1="${CGREEN}\u${CAQUA}@${CRED}\h${CAQUA}:${CBLUE}\w${NORMAL}\$(maybe_git_branch)"
+PS1="\$(maybe_git_branch)${CGREEN}\u${CAQUA}@${CRED}\h${CAQUA}:${CBLUE}\w${NORMAL}"
PS1="${PS1}\n${CGREEN}\$${CNORMAL} "
PROMPT_COMMAND="$CUSTOM_DIR/prompt-command"
bash_custom_prompt="true"

0 comments on commit 931ede5

Please sign in to comment.