Last active
January 5, 2024 21:17
-
-
Save wisnij/4558404 to your computer and use it in GitHub Desktop.
Bash $PS1
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
RED="\[\e[01;31m\]" | |
GREEN="\[\e[01;32m\]" | |
BLUE="\[\e[01;34m\]" | |
NORMAL="\[\e[00m\]" | |
JOBS='if [[ $(jobs) != "" ]]; then echo "(\j) "; fi' | |
STATUS="s=\$?; if [ \$s != 0 ]; then echo \"${RED}\$s${NORMAL} \"; fi" | |
HOST_COLOR="\[\e[1;38;5;$((22 + 10#$(hostname | cksum | cut -d' ' -f1) % 210))m\]" | |
case $USER in | |
root) | |
PROMPT_COLOR=$RED | |
;; | |
*) | |
PROMPT_COLOR=$GREEN | |
;; | |
esac | |
export PS1="${PROMPT_COLOR}[\t] \u${NORMAL}@${HOST_COLOR}\h ${BLUE}\w ${NORMAL}\$(${STATUS})\$(${JOBS})\\\$ " | |
unset PROMPT_COLOR HOST_COLOR STATUS JOBS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment