Skip to content

Instantly share code, notes, and snippets.

@fuzzy
Created May 22, 2016 17:36
Show Gist options
  • Save fuzzy/195369b9c5b03042b2c95014160222fd to your computer and use it in GitHub Desktop.
Save fuzzy/195369b9c5b03042b2c95014160222fd to your computer and use it in GitHub Desktop.
Color coding by platform: Supports Linux(Arch, Gentoo, Debian, Redhat, and derived systems), (Free|Net|Open)BSD, and OSX.
# Light shades
L_black="$(echo -e "\033[0;30m")"
L_red="$(echo -e "\033[0;31m")"
L_green="$(echo -e "\033[0;32m")"
L_brown="$(echo -e "\033[0;33m")"
L_blue="$(echo -e "\033[0;34m")"
L_purple="$(echo -e "\033[0;35m")"
L_cyan="$(echo -e "\033[0;36m")"
L_white="$(echo -e "\033[0;37m")"
# Bold shades
B_black="$(echo -e "\033[1;30m")"
B_red="$(echo -e "\033[1;31m")"
B_green="$(echo -e "\033[1;32m")"
B_brown="$(echo -e "\033[1;33m")"
B_blue="$(echo -e "\033[1;34m")"
B_purple="$(echo -e "\033[1;35m")"
B_cyan="$(echo -e "\033[1;36m")"
B_white="$(echo -e "\033[1;37m")"
# end it all!
endcolor="$(echo -e "\033[0m")"
case "$(uname -s)" in
(Linux)
if test -f /etc/arch-release; then
export PS1="\[${B_blue}\][\[${B_white}\]\@\[${B_blue}\]] \[${B_white}\]\u\[${B_purple}\]@\[${B_blue}\]\h \[${B_purple}\]\W\[${endcolor}\] > "
elif test -f /etc/redhat-release; then
export PS1="\[${B_red}\][\[${B_white}\]\@\[${B_red}\]] \[${B_white}\]\u\[${B_cyan}\]@\[${B_red}\]\h \[${B_cyan}\]\W\[${endcolor}\] > "
elif test -f /etc/debian_version; then
export PS1="\[${B_brown}\][\[${B_white}\]\@\[${B_brown}\]] \[${B_white}\]\u\[${B_green}\]@\[${B_brown}\]\h \[${B_green}\]\W\[${endcolor}\] > "
elif test -f /etc/gentoo-release; then
export PS1="\[${B_green}\][\[${B_white}\]\@\[${B_green}\]] \[${B_white}\]\u\[${B_brown}\]@\[${B_green}\]\h \[${B_brown}\]\W\[${endcolor}\] > "
fi
;;
(NetBSD)
export PS1="\[${B_brown}\][\[${B_white}\]\@\[${B_brown}\]] \[${B_white}\]\u\[${L_green}\]@\[${L_brown}\]\h \[${L_green}\]\W\[${endcolor}\] > "
;;
(FreeBSD)
export PS1="\[${B_red}\][\[${B_white}\]\@\[${B_red}\]] \[${B_white}\]\u\[${L_cyan}\]@\[${L_red}\]\h \[${L_cyan}\]\W\[${endcolor}\] > "
;;
(OpenBSD)
export PS1="\[${B_blue}\][\[${B_white}\]\@\[${B_blue}\]] \[${B_white}\]\u\[${L_purple}\]@\[${L_blue}\]\h \[${L_purple}\]\W\[${endcolor}\] > "
;;
(Darwin)
export PS1="\[${B_white}\][\[${L_white}\]\@\[${B_white}\]] \[${L_white}\]\u\[${B_white}\]@\[${L_white}\]\h \[${B_white}\]\W\[${endcolor}\] > "
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment