Skip to content

Instantly share code, notes, and snippets.

@valorin
Last active Feb 9, 2016
Embed
What would you like to do?
Git prompt + Byobu
##############
# THIS WORKS #
##############
##
# Git prompt options
##
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_SHOWCOLORHINTS=true
function myGitPS1() {
if [[ `pwd` == *workspace* ]]; then
__git_ps1 " (%s)"
fi
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;33m\]$(myGitPS1)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(myGitPS1)\$ '
fi
unset color_prompt force_color_prompt
################
# THIS DOESN'T #
################
"Ubuntu")
# Use Ubuntu colors (grey / aubergine / orange)
[ -n "$BYOBU_CHARMAP" ] || BYOBU_CHARMAP=$(locale charmap 2>/dev/null || echo)
PROMPT_COMMAND='prompt_status="$? "; if [[ $prompt_status == "0 " ]]; then prompt_status=; fi'
case "$BYOBU_CHARMAP" in
"UTF-8")
# MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET (U+27EB, Pe): ⟫
PS1="${debian_chroot:+($debian_chroot)}\[\e[38;5;202m\]\$prompt_status\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;5m\]\h\[\e[00m\]:\[\e[38;5;172m\]\w\[\e[00m\]\[\033[00;33m\]$(myGitPS1)\[\033[00m\]⟫ "
;;
*)
# Simple ASCII greater-than sign
PS1="${debian_chroot:+($debian_chroot)}\[\e[38;5;202m\]\$prompt_status\[\e[38;5;245m\]\u\[\e[00m\]@\[\e[38;5;5m\]\h\[\e[00m\]:\[\e[38;5;172m\]\w\[\e[00m\]\[\033[00;33m\]$(myGitPS1)\[\033[00m\]> "
;;
esac
;;
*)
# Use Byobu colors (green / blue / red)
PS1="${debian_chroot:+($debian_chroot)}\[\e[31m\]\$prompt_status\[\e[00;32m\]\u\[\e[00m\]@\[\e[00;36m\]\h\[\e[00m\]:\[\e[00;31m\]\w\[\e[00m\]\[\033[01;33m\]$(myGitPS1)\[\033[00m\]\$ "
;;
###############################
# THIS IS WHAT I SEE IN BYOBU #
###############################
valorin@gandalf:~/workspace/scripts (master %=)⟫ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
valorin@gandalf:~/workspace/scripts (master %=)⟫ . ~/.bashrc
valorin@gandalf:~/workspace/scripts (master>)⟫
@AlexSysadmin
Copy link

AlexSysadmin commented Feb 9, 2016

Where do i put this ?

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment