Created
September 9, 2020 17:08
-
-
Save alexandre1985/ecbd28cd403a79b8c3a9c46260e32284 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" | |
# Screenshot: http://cloud.gf3.ca/M5rG | |
# A big thanks to \amethyst on Freenode | |
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then | |
export TERM=gnome-256color | |
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then | |
export TERM=xterm-256color | |
fi | |
MAGENTA="\033[1;31m" | |
ORANGE="\033[1;33m" | |
GREEN="\033[1;32m" | |
PURPLE="\033[1;35m" | |
WHITE="\033[1;37m" | |
CYAN="\033[1;36m" | |
BLUE="\033[1;34m" | |
BLACK="\033[1;30m" | |
BOLD="" | |
RESET="\033[m" | |
function prompt_command() { | |
# if root user | |
if [ $(id -u) -eq 0 ]; then | |
# with cyan | |
PS1="\[${BOLD}${MAGENTA}\]\u \[$CYAN\]at \[$ORANGE\]\h \[$CYAN\]in \[$GREEN\]\w\[$CYAN\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$CYAN\]\n# \[$RESET\]" | |
else | |
# with cyan | |
PS1="\[${BOLD}${MAGENTA}\]\u \[$CYAN\]at \[$ORANGE\]\h \[$CYAN\]in \[$GREEN\]\w\[$CYAN\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$CYAN\]\n\$ \[$RESET\]" | |
fi | |
} | |
parse_git_dirty () { | |
[[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" | |
} | |
parse_git_branch () { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" | |
} | |
prompt_command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment