Created
May 14, 2021 07:41
-
-
Save shreyansp/6200f5187ae1e3614861f3213066b5d8 to your computer and use it in GitHub Desktop.
.bashrc
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
## Colors? Used for the prompt. | |
#Regular text color | |
BLACK='\[\e[0;30m\]' | |
#Bold text color | |
BBLACK='\[\e[1;30m\]' | |
#background color | |
BGBLACK='\[\e[40m\]' | |
RED='\[\e[0;31m\]' | |
BRED='\[\e[1;31m\]' | |
BGRED='\[\e[41m\]' | |
GREEN='\[\e[0;32m\]' | |
BGREEN='\[\e[1;32m\]' | |
BGGREEN='\[\e[1;32m\]' | |
YELLOW='\[\e[0;33m\]' | |
BYELLOW='\[\e[1;33m\]' | |
BGYELLOW='\[\e[1;33m\]' | |
BLUE='\[\e[0;34m\]' | |
BBLUE='\[\e[1;34m\]' | |
BGBLUE='\[\e[1;34m\]' | |
MAGENTA='\[\e[0;35m\]' | |
BMAGENTA='\[\e[1;35m\]' | |
BGMAGENTA='\[\e[1;35m\]' | |
CYAN='\[\e[0;36m\]' | |
BCYAN='\[\e[1;36m\]' | |
BGCYAN='\[\e[1;36m\]' | |
WHITE='\[\e[0;37m\]' | |
BWHITE='\[\e[1;37m\]' | |
BGWHITE='\[\e[1;37m\]' | |
PROMPT_COMMAND=smile_prompt | |
parse_git_branch() { | |
# return $(/usr/bin/git symbolic-ref --short HEAD) #| sed -n 's/feature/f/p;s/git_barx_fx_srp/srp/p' | |
GIT_BRANCH="$(/usr/bin/git symbolic-ref --short HEAD 2>/dev/null)" # | sed -n 's/.*\/\(.*\)/\1/p') | |
#GIT_BRANCH="$(/usr/bin/git branch 2> /dev/null | grep -e "^*" | cut -c2-)" | |
#/usr/bin/git branch 2> /dev/null | grep -e "^*" | cut -c2- | |
if [[ ! -z "${GIT_BRANCH// }" ]]; then | |
if [[ "${GIT_BRANCH,,}" == *"srp"* ]]; then | |
GIT_BRANCH=$(sed -n 's/.*\/\(.*\)/\1/p' <<< $GIT_BRANCH) | |
fi | |
echo "(${GIT_BRANCH})" | |
fi | |
} | |
function smile_prompt | |
{ | |
if [ "$?" -eq "0" ] | |
then | |
#smiley | |
SC="${GREEN}:)" | |
else | |
#frowney | |
SC="${RED}:(" | |
fi | |
if [[ $USER =~ "sys" ]] | |
then | |
#root user color | |
UC="${BRED}" | |
else | |
#normal user color | |
UC="${BGREEN}" | |
fi | |
if [[ $HOSTNAME =~ "pr" ]] | |
then | |
#root user color | |
HC="${RED}" | |
else | |
#normal user color | |
HC="${GREEN}" | |
fi | |
#regular color | |
RC="${BWHITE}" | |
#default color | |
DF='\[\e[0m\]' | |
#PS1="[${UC}\u${RC}@${HC}\h ${RC}\W${DF}] ${SC}${DF} " | |
if [[ $USER =~ "sys" ]] | |
then | |
PS1=" ${SC} ${CYAN}[\D{%d %H:%M:%S}] ${UC}\u${DF}@${HC}\h${DF}:${BBLUE}\w${DF}\$ " | |
else | |
PS1=" ${SC} ${CYAN}[\D{%d %H:%M:%S}] ${UC}\u${DF}@${HC}\h${DF}:${BBLUE}\w${BYELLOW}$(parse_git_branch)\n${DF}\$ " | |
fi | |
#PS1=" ${SC} ${UC}\u${DF}@${HC}\h${DF}:${BBLUE}\w${BYELLOW}($(parse_git_branch))\n${DF}\$ " | |
#PS1=" ${SC} ${UC}\u${DF}@${HC}\h${DF}:${BBLUE}\w${BYELLOW}${DF}\$ " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment