hopefully fix bash overriding PS1
This commit is contained in:
parent
0eee969d73
commit
7643cba0d1
69
bash/bashrc
69
bash/bashrc
@ -83,8 +83,8 @@ if [ -x "$(command -v tput)" ]; then
|
||||
reset="\[$(tput sgr0)\]"; unesc_reset="$(tput sgr0)"
|
||||
bold="\[$(tput bold)\]"; unesc_bold="$(tput bold)"
|
||||
fi
|
||||
# fallback to ANSI esacpe codes
|
||||
else
|
||||
# fallback to ANSI esacpe codes
|
||||
black="\[\033[0;30m\]"; unesc_black="\033[0;30m"
|
||||
red="\[\033[1;31m\]"; unesc_red="\033[1;31m"
|
||||
green="\[\033[1;32m\]"; unesc_green="\033[1;32m"
|
||||
@ -176,42 +176,57 @@ parse_git() {
|
||||
BRANCH="$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
|
||||
STATUS="$(git status 2> /dev/null)"
|
||||
|
||||
# colors are unescaped because the whole function should be escaped in PS1
|
||||
if [[ $? -ne 0 ]]; then return; else printf "${unesc_reset}${unesc_bold}%s" ":(${BRANCH})["; fi
|
||||
if echo "${STATUS}" | grep -c "nothing to commit" &> /dev/null; then printf "${unesc_blue}%s" "="; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then printf "${unesc_red}%s" "%"; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "deleted:" &> /dev/null; then printf "${unesc_red}%s" "-"; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "new file:" &> /dev/null; then printf "${unesc_green}%s" "+"; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then printf "${unesc_yellow}%s" ">"; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "branch is behind" &> /dev/null; then printf "${unesc_yellow}%s" "<"; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then printf "${unesc_yellow}%s" "?"; else printf ""; fi
|
||||
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then printf "${unesc_yellow}%s" "*"; else printf ""; fi
|
||||
printf "${unesc_white}%s" "]"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
return
|
||||
else
|
||||
printf "\001${unesc_reset}${unesc_bold}\002:(%s)" "${BRANCH}"
|
||||
printf "\001${unesc_white}\002%s" "["
|
||||
if echo "${STATUS}" | grep -c "nothing to commit" &> /dev/null; then
|
||||
printf "\001${unesc_blue}\002%s" "=";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then
|
||||
printf "\001${unesc_red}\002%s" "%";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "deleted:" &> /dev/null; then
|
||||
printf "\001${unesc_red}\002%s" "-";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "new file:" &> /dev/null; then
|
||||
printf "\001${unesc_green}\002%s" "+";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then
|
||||
printf "\001${unesc_yellow}\002%s" ">";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "branch is behind" &> /dev/null; then
|
||||
printf "\001${unesc_yellow}\002%s" "<";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then
|
||||
printf "\001${unesc_yellow}\002%s" "?";
|
||||
fi
|
||||
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then
|
||||
printf "\001${unesc_yellow}\002%s" "*";
|
||||
fi
|
||||
printf "\001${unesc_white}\002%s" "]"
|
||||
fi
|
||||
}
|
||||
|
||||
# PROMPTS
|
||||
# -------
|
||||
# ***non-color prompts***
|
||||
|
||||
# ***common prompts***
|
||||
# PS1="\W \\$ "
|
||||
# PS1="[\u@\h:\W]\\$ "
|
||||
PS1="\u@\h:\W\\$ "
|
||||
# PS1="[\t] \u@\h:\W\\$ "
|
||||
# PS1="\u@\h:\W\\$ "
|
||||
|
||||
# start prompt string
|
||||
# PS1="${bold}"
|
||||
# ***color prompts***
|
||||
# PS1="${blue}\W ${yellow}\\$ "
|
||||
# PS1="${purple}\u${yellow}@${cyan}\h${white}:${blue}\W ${yellow}\\$ "
|
||||
|
||||
# ***git prompts***
|
||||
# PS1+="${blue}\w\[\$(parse_git)\] ${cyan}\\$ "
|
||||
# PS1+="${white}[\t] ${blue}\W\[\$(parse_git)\] ${green}\\$ "
|
||||
# PS1+="${purple}\u${yellow}@${cyan}\h${white}:${blue}\W\[\$(parse_git)\]${green}\\$ "
|
||||
# PS1+="\n${cyan}\u ${white}at ${yellow}\h ${white}in ${blue}\w ${white}on \[\$(parse_git)\]\n${yellow}\\$ "
|
||||
# PS1="${bold}${blue}\W\$(parse_git)${cyan} \\$ ${reset}"
|
||||
PS1="${bold}${white}\t ${blue}\W\$(parse_git) ${cyan}\\$ ${reset}"
|
||||
# PS1="${bold}${purple}\u${yellow}@${cyan}\h${white}:${blue}\W\$(parse_git)${green} \\$ ${reset}"
|
||||
# PS1="${bold}\n${cyan}\u ${white}at ${yellow}\h ${white}in ${blue}\w ${white}on \$(parse_git)\n${yellow}\\$ ${reset}"
|
||||
|
||||
# ***non git prompts***
|
||||
# PS1+="${blue}\W ${yellow}\\$ "
|
||||
# PS1+="${purple}\u${yellow}@${cyan}\h${white}:${blue}\W ${yellow}\\$ "
|
||||
|
||||
# end prompt string
|
||||
# PS1+="${reset}"
|
||||
|
||||
# BASH AUTOCOMPLETION
|
||||
# -------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user