Last active
October 13, 2015 22:28
-
-
Save hh10k/3e67b4aec509f60f1475 to your computer and use it in GitHub Desktop.
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 install_prompt { | |
local DEFAULT="\[\e[0m\]" | |
local RED="\[\e[31m\]" | |
local GREEN="\[\e[32m\]" | |
local YELLOW_BOLD="\[\e[1;33m\]" | |
local BLUE="\[\e[34m\]" | |
local WHITE="\[\e[37m\]" | |
local WHITE_BOLD="\[\e[1;37m\]" | |
local MAGENTA_BOLD="\[\e[1;35m\]" | |
local MACHINE_COLOR="$WHITE_BOLD" | |
local ROOT_COLOR="$YELLOW_BOLD" | |
PS1="\`\ | |
if [ \$? -eq 0 ]; then R='$GREEN'; else R='$RED'; fi;\ | |
if [ \$EUID -eq 0 ]; then printf '$ROOT_COLOR'; else printf '$MACHINE_COLOR'; fi;\ | |
printf '\u$MACHINE_COLOR@\h $DEFAULT\W';\ | |
B=\$(git describe --all --always 2>/dev/null);\ | |
if [ -n \"\$B\" ]; then printf \"$BLUE[\${B##*/}]\"; fi;\ | |
printf \$R\ | |
\`\$$DEFAULT " | |
} | |
install_prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment