Last active
February 6, 2019 20:54
-
-
Save LuD1161/86cc3db8f8283e235fe679a05dea69fd to your computer and use it in GitHub Desktop.
My 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
#!/bin/bash | |
#========================================================= | |
#Terminal Color Codes | |
#========================================================= | |
WHITE='\[\033[1;37m\]' | |
LIGHTGRAY='\[\033[0;37m\]' | |
GRAY='\[\033[1;30m\]' | |
BLACK='\[\033[0;30m\]' | |
RED='\[\033[0;31m\]' | |
LIGHTRED='\[\033[1;31m\]' | |
GREEN='\[\033[0;32m\]' | |
LIGHTGREEN='\[\033[1;32m\]' | |
BROWN='\[\033[0;33m\]' #Orange | |
YELLOW='\[\033[1;33m\]' | |
BLUE='\[\033[0;34m\]' | |
LIGHTBLUE='\[\033[1;34m\]' | |
PURPLE='\[\033[0;35m\]' | |
PINK='\[\033[1;35m\]' #Light Purple | |
CYAN='\[\033[0;36m\]' | |
LIGHTCYAN='\[\033[1;36m\]' | |
DEFAULT='\[\033[0m\]' | |
# Colors | |
cLINES=$GRAY #Lines and Arrow | |
cBRACKETS=$GRAY # Brackets around each data item | |
cERROR=$LIGHTRED # Error block when previous command did not return 0 | |
cTIME=$LIGHTGRAY # The current time | |
cMPX1=$YELLOW # Color for terminal multiplexer threshold 1 | |
cMPX2=$RED # Color for terminal multiplexer threshold 2 | |
cBGJ1=$YELLOW # Color for background job threshold 1 | |
cBGJ2=$RED # Color for background job threshold 2 | |
cSTJ1=$YELLOW # Color for background job threshold 1 | |
cSTJ2=$RED # Color for background job threshold 2 | |
cSSH=$PINK # Color for brackets if session is an SSH session | |
cUSR=$LIGHTBLUE # Color of user | |
cUHS=$GRAY # Color of the user and hostname separator, probably '@' | |
cHST=$LIGHTGREEN # Color of hostname | |
cRWN=$RED # Color of root warning | |
cPWD=$BLUE # Color of current directory | |
cCMD=$DEFAULT # Color of the command you type | |
# Removed this, as unnecessary | |
fileDetails="(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files" | |
#========================================================= | |
# Backgrounded running jobs | |
#========================================================= | |
# BGJC=$(jobs -r | wc -l ) | |
# if [ $BGJC -gt 0 ] ; then | |
# jobs="${connectingLine}(${cSTJ1}\j${cLINES})" | |
# else | |
# jobs="" | |
# fi | |
# TODO : Implement jobs display | |
jobs="" | |
currDir="[${cPWD}\w${cBRACKETS}]" | |
connectingLine="\342\224\200" # connectingLine ==> "-" | |
# Start PS1 | |
PS1="\n" | |
PS1="${PS1}${cLINES}\342\224\214\342\224\200" | |
# If root user, color = red | |
if [ "`id -u`" -eq 0 ]; then | |
PS1="${PS1}[${cRWN}\u" | |
else | |
PS1="${PS1}[${cUSR}\u" | |
fi | |
PS1="${PS1}${cUHS}@${cHST}\h${cLINES}]${jobs}${cLINES}${connectingLine}[${cTIME}\t \d${cLINES}]${connectingLine}${currDir}\n" | |
# 2nd Line of PS1 | |
PS1="${PS1}${cLINES}\342\224\224\342\224\200\342\224\200> ${cCMD}" | |
PROMPT_COMMAND='echo -ne "\033]0;${PWD}\007"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment