more cleanup
This commit is contained in:
parent
70e6a0c97c
commit
2591009372
97
bash/bashrc
97
bash/bashrc
@ -68,28 +68,33 @@ alias venvac='source venv/bin/activate'
|
|||||||
# COLORS
|
# COLORS
|
||||||
# ------
|
# ------
|
||||||
# color vars using tput or ANSI/VT100 Control sequences
|
# color vars using tput or ANSI/VT100 Control sequences
|
||||||
if command -v "tput" > /dev/null 2>&1 ; then
|
# check if tput is available
|
||||||
black="\[$(tput setaf 0)\]"
|
if [ -x "$(command -v tput)" ]; then
|
||||||
red="\[$(tput setaf 1)\]"
|
num_colors=$(tput colors)
|
||||||
green="\[$(tput setaf 2)\]"
|
if [ -n "$num_colors" ] && [ "$num_colors" -ge 8 ]; then
|
||||||
yellow="\[$(tput setaf 3)\]"
|
black="\[$(tput setaf 0)\]"; unesc_black="$(tput setaf 0)"
|
||||||
blue="\[$(tput setaf 4)\]"
|
red="\[$(tput setaf 1)\]"; unesc_red="$(tput setaf 1)"
|
||||||
purple="\[$(tput setaf 5)\]"
|
green="\[$(tput setaf 2)\]"; unesc_green="$(tput setaf 2)"
|
||||||
cyan="\[$(tput setaf 6)\]"
|
yellow="\[$(tput setaf 3)\]"; unesc_yellow="$(tput setaf 3)"
|
||||||
white="\[$(tput setaf 7)\]"
|
blue="\[$(tput setaf 4)\]"; unesc_blue="$(tput setaf 4)"
|
||||||
reset="\[$(tput sgr0)\]"
|
purple="\[$(tput setaf 5)\]"; unesc_purple="$(tput setaf 5)"
|
||||||
bold="\[$(tput bold)\]"
|
cyan="\[$(tput setaf 6)\]"; unesc_cyan="$(tput setaf 6)"
|
||||||
|
white="\[$(tput setaf 7)\]"; unesc_white="$(tput setaf 7)"
|
||||||
|
reset="\[$(tput sgr0)\]"; unesc_reset="$(tput sgr0)"
|
||||||
|
bold="\[$(tput bold)\]"; unesc_bold="$(tput bold)"
|
||||||
|
fi
|
||||||
|
# fallback to ANSI esacpe codes
|
||||||
else
|
else
|
||||||
black="\[\033[0;30\]"
|
black="\[\033[0;30m\]"; unesc_black="\033[0;30m"
|
||||||
red="\[\033[1;31\]"
|
red="\[\033[1;31m\]"; unesc_red="\033[1;31m"
|
||||||
green="\[\033[1;32\]"
|
green="\[\033[1;32m\]"; unesc_green="\033[1;32m"
|
||||||
yellow="\[\033[1;33\]"
|
yellow="\[\033[1;33m\]"; unesc_yellow="\033[1;33m"
|
||||||
blue="\[\033[1;34\]"
|
blue="\[\033[1;34m\]"; unesc_blue="\033[1;34m"
|
||||||
purple="\[\033[1;35\]"
|
purple="\[\033[1;35m\]"; unesc_purple="\033[1;35m"
|
||||||
cyan="\[\033[1;36\]"
|
cyan="\[\033[1;36m\]"; unesc_cyan="\033[1;36m"
|
||||||
white="\[\033[1;37\]"
|
white="\[\033[1;37m\]"; unesc_white="\033[1;37m"
|
||||||
reset="\[\033[0m\]"
|
reset="\[\033[0m\]"; unesc_reset="\033[0m"
|
||||||
bold="\[\033[1m\]"
|
bold="\[\033[1m\]"; unesc_bold="\033[1m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
@ -168,50 +173,44 @@ lg() { lazygit "$*"; }
|
|||||||
|
|
||||||
# git prompt function
|
# git prompt function
|
||||||
parse_git() {
|
parse_git() {
|
||||||
# ways to get branches
|
|
||||||
# git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
|
|
||||||
# git rev-parse --abbrev-ref HEAD 2> /dev/null | sed -e 's/.*\/\(.*\)/\1/'
|
|
||||||
|
|
||||||
BRANCH="$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
|
BRANCH="$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
|
||||||
STATUS="$(git status 2> /dev/null)"
|
STATUS="$(git status 2> /dev/null)"
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then return; else printf "$(tput sgr0)$(tput bold)%s" ":(${BRANCH})["; fi
|
# 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 "$(tput setaf 4)%s" "="; else printf ""; 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 "renamed:" &> /dev/null; then printf "$(tput setaf 1)%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 "deleted:" &> /dev/null; then printf "$(tput setaf 1)%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 "new file:" &> /dev/null; then printf "$(tput setaf 2)%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 "Untracked files:" &> /dev/null; then printf "${unesc_yellow}%s" "?"; else printf ""; fi
|
||||||
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then printf "$(tput setaf 3)%s" "!"; else printf ""; fi
|
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then printf "${unesc_yellow}%s" "*"; else printf ""; fi
|
||||||
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then printf "$(tput setaf 3)%s" "?"; else printf ""; fi
|
printf "${unesc_white}%s" "]"
|
||||||
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then printf "$(tput setaf 3)%s" "*"; else printf ""; fi
|
|
||||||
|
|
||||||
printf "$(tput setaf 7)%s" "]"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# PROMPTS
|
# PROMPTS
|
||||||
# -------
|
# -------
|
||||||
# start prompt string
|
# start prompt string
|
||||||
PS1="${bold}"
|
# PS1="${bold}"
|
||||||
|
|
||||||
# ***git prompts***
|
# ***git prompts***
|
||||||
# PS1+="${blue}\w\[\$(parse_git)\] ${cyan}\\$ "
|
# PS1+="${blue}\w\[\$(parse_git)\] ${cyan}\\$ "
|
||||||
PS1+="${white}[\t] ${blue}\w\[\$(parse_git)\] ${green}\\$ "
|
# PS1+="${white}[\t] ${blue}\W\[\$(parse_git)\] ${green}\\$ "
|
||||||
# PS1+="${purple}\u${yellow}@${cyan}\h${white}:${blue}\w\[\$(parse_git)\]${yellow} \\$ "
|
# 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+="\n${cyan}\u ${white}at ${yellow}\h ${white}in ${blue}\w ${white}on \[\$(parse_git)\]\n${yellow}\\$ "
|
||||||
|
|
||||||
# ***non git prompts***
|
# ***non git prompts***
|
||||||
# PS1+="${blue}\w ${yellow}\\$ "
|
# PS1+="${blue}\W ${yellow}\\$ "
|
||||||
# PS1+="${purple}\u${yellow}@${cyan}\h${white}:${blue}\w ${yellow}\\$ "
|
# PS1+="${purple}\u${yellow}@${cyan}\h${white}:${blue}\W ${yellow}\\$ "
|
||||||
|
|
||||||
# ***non-color prompts***
|
|
||||||
# PS1="\w \\$ "
|
|
||||||
# PS1="[\u@\h:\w] \\$ "
|
|
||||||
# PS1="\u@\h:\w \\$ "
|
|
||||||
|
|
||||||
# end prompt string
|
# end prompt string
|
||||||
PS1+="${reset}"
|
# PS1+="${reset}"
|
||||||
|
|
||||||
|
# ***non-color prompts***
|
||||||
|
# PS1="\W \\$ "
|
||||||
|
# PS1="[\u@\h:\W]\\$ "
|
||||||
|
PS1="\u@\h:\W\\$ "
|
||||||
|
|
||||||
|
|
||||||
# BASH AUTOCOMPLETION
|
# BASH AUTOCOMPLETION
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user