Skip to content

Instantly share code, notes, and snippets.

@Trucido
Created May 21, 2018 09:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Trucido/b53c3ba5d64e53f38066f3b5522b12fc to your computer and use it in GitHub Desktop.
Save Trucido/b53c3ba5d64e53f38066f3b5522b12fc to your computer and use it in GitHub Desktop.
# .bash_prompt
BASE0=$'\E[38;5;244m'
BASE00=$'\E[38;5;241m'
BASE01=$'\E[38;5;240m'
BASE02=$'\E[38;5;235m'
BASE03=$'\E[38;5;234m'
BASE1=$'\E[38;5;245m'
BASE2=$'\E[38;5;254m'
BASE3=$'\E[38;5;230m'
BLUE=$'\E[38;5;33m'
BOLD=$'\E[1m'
CYAN=$'\E[38;5;37m'
GREEN=$'\E[38;5;64m'
NORMAL_GREEN=$'\E[38;5;32m'
BOLD_GREEN=$'\E[00;1;32m'
MAGENTA=$'\E[38;5;125m'
ORANGE=$'\E[38;5;166m'
RED=$'\E[38;5;160m'
BOLD_RED=$'\E[00;1;31m'
NORMAL_RED=$'\E[38;5;31m'
RESET=$'\E(B\E[m'
VIOLET=$'\E[38;5;61m'
YELLOW=$'\E[38;5;136m'
# If we're root, then let's see red
# (Note: the short circuits below are intentional to avoid unnecessary tests)
if [ -z "$IS_WSL" ] || ! grep -iq microsoft /proc/version; then
if [ "${EUID}" = "0" ] || [ "$USER" = "root" ] ; then
USER_COLOR=$'\E[38;5;160m'
# PROMPT_COLOR=$'\E[38;5;160m'
elif [ "${EUID}" -ge "1000" ] || [ "$(id -u)" -ge "1000" ]; then
USER_COLOR=$'\E[38;5;64m'
# PROMPT_COLOR=$'\E[38;5;32m'
else
USER_COLOR=$'\E[38;5;245m'
fi
else
# if we're in WSL use ms blue
# or not, just change user color. #HOST_COLOR=$'\E[38;5;33m'
USER_COLOR=$'\E[01;34m'
fi
# Host color for common distros.
case "$(grep -E '^NAME=' /etc/os-release)" in
*Leap*)
HOST_COLOR=$'\E[00;0;32m'
;;
*Tumbleweed*)
HOST_COLOR=$'\E[38;5;37m'
;;
*SLE*)
HOST_COLOR=$'\E[38;5;64m'
;;
*Debian*)
HOST_COLOR=$'\E[38;5;31m'
;;
*Kali*)
HOST_COLOR=$'\E[38;5;160m'
;;
*Sparky*)
HOST_COLOR=$'\E[38;5;160m'
;;
*OpenMediaVault*)
HOST_COLOR=$'\E[38;5;61m'
;;
*Fedora*)
HOST_COLOR=$'\E[38;5;33m'
;;
"*Red Hat*")
HOST_COLOR=$'\E[38;5;160m'
;;
*CentOS*)
HOST_COLOR=$'\E[38;5;61m'
;;
*Ubuntu*)
HOST_COLOR=$'\E[38;5;166m'
;;
*)
HOST_COLOR=$'\E[38;5;245m'
;;
esac
## Check if we're root or local or remote
#if [ "${EUID}" = "0" ] || [ "$USER" = "root" ] || [[ "${SSH_CLIENT}" || -n "${SSH_TTY}" ]] ; then
# # Prompt with hostname
# PS1="\[${RESET}\][\[${BASE0}\]\A\[${RESET}\] \[${USER_COLOUR}\]\u@\h \[${CYAN}\]\w\[${YELLOW}\]\$(__git_ps1 \" (%s)\")\[${RESET}\]]\\$\[${RESET}\] "
#elif [ "${EUID}" -ge "1000" ]; then
# # Just prompt
# PS1="\[${RESET}\][\[${BASE0}\]\A\[${RESET}\] \[${USER_COLOUR}\]\u \[${CYAN}\]\w\[${YELLOW}\]\$(__git_ps1 \" (%s)\")\[${RESET}\]]\\$\[${RESET}\] "
#fi
if [ "${EUID}" = "0" ] || [ "$USER" = "root" ];then
PS1="\[${RESET}\][\[${BASE0}\]\A\[${RESET}\] \[${USER_COLOR}\]\u\[${RESET}\]\[${BASE0}\]@\[${HOST_COLOR}\]\h \[${CYAN}\]\w\[${YELLOW}\]\$(__git_ps1 \" (%s)\")\[${RESET}\]]\[\e[00;31m\]#\[${RESET}\] "
elif [ "${EUID}" -ge "1000" ] || [ "$(id -u)" -ge "1000" ]; then
PS1="\[${RESET}\][\[${BASE0}\]\A\[${RESET}\] \[${USER_COLOR}\]\u\[${RESET}\]\[${BASE0}\]@\[${HOST_COLOR}\]\h \[${CYAN}\]\w\[${YELLOW}\]\$(__git_ps1 \" (%s)\")\[${RESET}\]]\[\e[00;32m\]\$\[${RESET}\] "
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment