hopefully fix bash overriding PS1
This commit is contained in:
parent
0eee969d73
commit
7643cba0d1
91
bash/bashrc
91
bash/bashrc
@ -83,8 +83,8 @@ if [ -x "$(command -v tput)" ]; then
|
|||||||
reset="\[$(tput sgr0)\]"; unesc_reset="$(tput sgr0)"
|
reset="\[$(tput sgr0)\]"; unesc_reset="$(tput sgr0)"
|
||||||
bold="\[$(tput bold)\]"; unesc_bold="$(tput bold)"
|
bold="\[$(tput bold)\]"; unesc_bold="$(tput bold)"
|
||||||
fi
|
fi
|
||||||
# fallback to ANSI esacpe codes
|
|
||||||
else
|
else
|
||||||
|
# fallback to ANSI esacpe codes
|
||||||
black="\[\033[0;30m\]"; unesc_black="\033[0;30m"
|
black="\[\033[0;30m\]"; unesc_black="\033[0;30m"
|
||||||
red="\[\033[1;31m\]"; unesc_red="\033[1;31m"
|
red="\[\033[1;31m\]"; unesc_red="\033[1;31m"
|
||||||
green="\[\033[1;32m\]"; unesc_green="\033[1;32m"
|
green="\[\033[1;32m\]"; unesc_green="\033[1;32m"
|
||||||
@ -149,22 +149,22 @@ bkup() {
|
|||||||
|
|
||||||
# hugo -- create and edit a new post
|
# hugo -- create and edit a new post
|
||||||
new-post() {
|
new-post() {
|
||||||
postname=""
|
postname=""
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo -n "Please enter a postname: "
|
echo -n "Please enter a postname: "
|
||||||
read -r postname
|
read -r postname
|
||||||
else
|
else
|
||||||
postname="$1"
|
postname="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
post_filename="$postname.md"
|
post_filename="$postname.md"
|
||||||
blog_dir="$HOME/src/blog"
|
blog_dir="$HOME/src/blog"
|
||||||
local_url="http://localhost:1313/posts/$postname"
|
local_url="http://localhost:1313/posts/$postname"
|
||||||
|
|
||||||
hugo new -s "$blog_dir" "posts/$post_filename"
|
hugo new -s "$blog_dir" "posts/$post_filename"
|
||||||
hugo serve -s "$blog_dir" -D &> /dev/null &
|
hugo serve -s "$blog_dir" -D &> /dev/null &
|
||||||
xdg-open "$local_url" &> /dev/null &
|
xdg-open "$local_url" &> /dev/null &
|
||||||
vim "$blog_dir/content/posts/$post_filename" && kill %1
|
vim "$blog_dir/content/posts/$post_filename" && kill %1
|
||||||
}
|
}
|
||||||
|
|
||||||
# git
|
# git
|
||||||
@ -176,42 +176,57 @@ parse_git() {
|
|||||||
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)"
|
||||||
|
|
||||||
# colors are unescaped because the whole function should be escaped in PS1
|
if [[ $? -ne 0 ]]; then
|
||||||
if [[ $? -ne 0 ]]; then return; else printf "${unesc_reset}${unesc_bold}%s" ":(${BRANCH})["; fi
|
return
|
||||||
if echo "${STATUS}" | grep -c "nothing to commit" &> /dev/null; then printf "${unesc_blue}%s" "="; else printf ""; fi
|
else
|
||||||
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then printf "${unesc_red}%s" "%"; else printf ""; fi
|
printf "\001${unesc_reset}${unesc_bold}\002:(%s)" "${BRANCH}"
|
||||||
if echo "${STATUS}" | grep -c "deleted:" &> /dev/null; then printf "${unesc_red}%s" "-"; else printf ""; fi
|
printf "\001${unesc_white}\002%s" "["
|
||||||
if echo "${STATUS}" | grep -c "new file:" &> /dev/null; then printf "${unesc_green}%s" "+"; else printf ""; fi
|
if echo "${STATUS}" | grep -c "nothing to commit" &> /dev/null; then
|
||||||
if echo "${STATUS}" | grep -c "branch is ahead:" &> /dev/null; then printf "${unesc_yellow}%s" ">"; else printf ""; fi
|
printf "\001${unesc_blue}\002%s" "=";
|
||||||
if echo "${STATUS}" | grep -c "branch is behind" &> /dev/null; then printf "${unesc_yellow}%s" "<"; else printf ""; fi
|
fi
|
||||||
if echo "${STATUS}" | grep -c "Untracked files:" &> /dev/null; then printf "${unesc_yellow}%s" "?"; else printf ""; fi
|
if echo "${STATUS}" | grep -c "renamed:" &> /dev/null; then
|
||||||
if echo "${STATUS}" | grep -c "modified:" &> /dev/null; then printf "${unesc_yellow}%s" "*"; else printf ""; fi
|
printf "\001${unesc_red}\002%s" "%";
|
||||||
printf "${unesc_white}%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
|
# PROMPTS
|
||||||
# -------
|
# -------
|
||||||
# ***non-color prompts***
|
|
||||||
|
# ***common prompts***
|
||||||
# PS1="\W \\$ "
|
# PS1="\W \\$ "
|
||||||
# PS1="[\u@\h:\W]\\$ "
|
# PS1="[\u@\h:\W]\\$ "
|
||||||
PS1="\u@\h:\W\\$ "
|
# PS1="\u@\h:\W\\$ "
|
||||||
# PS1="[\t] \u@\h:\W\\$ "
|
|
||||||
|
|
||||||
# start prompt string
|
# ***color prompts***
|
||||||
# PS1="${bold}"
|
# PS1="${blue}\W ${yellow}\\$ "
|
||||||
|
# PS1="${purple}\u${yellow}@${cyan}\h${white}:${blue}\W ${yellow}\\$ "
|
||||||
|
|
||||||
# ***git prompts***
|
# ***git prompts***
|
||||||
# PS1+="${blue}\w\[\$(parse_git)\] ${cyan}\\$ "
|
# PS1="${bold}${blue}\W\$(parse_git)${cyan} \\$ ${reset}"
|
||||||
# PS1+="${white}[\t] ${blue}\W\[\$(parse_git)\] ${green}\\$ "
|
PS1="${bold}${white}\t ${blue}\W\$(parse_git) ${cyan}\\$ ${reset}"
|
||||||
# PS1+="${purple}\u${yellow}@${cyan}\h${white}:${blue}\W\[\$(parse_git)\]${green}\\$ "
|
# PS1="${bold}${purple}\u${yellow}@${cyan}\h${white}:${blue}\W\$(parse_git)${green} \\$ ${reset}"
|
||||||
# PS1+="\n${cyan}\u ${white}at ${yellow}\h ${white}in ${blue}\w ${white}on \[\$(parse_git)\]\n${yellow}\\$ "
|
# 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
|
# BASH AUTOCOMPLETION
|
||||||
# -------------------
|
# -------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user