Created
January 28, 2016 11:51
-
-
Save tkalve/2d8b4685aee1334ba55a to your computer and use it in GitHub Desktop.
Colored bash 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
function color_my_prompt { | |
local __user_and_host="\[$(tput bold)\]\[\033[38;5;198m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;255m\] at \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;214m\]\h\[$(tput sgr0)\]" | |
local __cur_location="\[\033[38;5;255m\]in \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;154m\]\w\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\]" | |
local __git_branch_color="\[$(tput sgr0)\]\[\033[38;5;247m\]" | |
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`' | |
local __prompt_tail="\n\[$(tput sgr0)\]\[\033[38;5;255m\]\\$\[$(tput sgr0)\]" | |
local __last_color="\[\033[00m\]" | |
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color " | |
} | |
color_my_prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will give a colored prompt in the following format:
and show the current git branch like this: