bash: fix terminal wrapping with prompt
This commit is contained in:
@@ -11,29 +11,29 @@ alias highlight='grep -U999999 --color=always'
|
|||||||
|
|
||||||
export PATH=$PATH:$HOME/.mgr_config/bin
|
export PATH=$PATH:$HOME/.mgr_config/bin
|
||||||
|
|
||||||
FG_BLK="$(tput setaf 0)"
|
FG_BLK="\001$(tput setaf 0)\002"
|
||||||
FG_RED="$(tput setaf 1)"
|
FG_RED="\001$(tput setaf 1)\002"
|
||||||
FG_GRN="$(tput setaf 2)"
|
FG_GRN="\001$(tput setaf 2)\002"
|
||||||
FG_YEL="$(tput setaf 3)"
|
FG_YEL="\001$(tput setaf 3)\002"
|
||||||
FG_BLU="$(tput setaf 4)"
|
FG_BLU="\001$(tput setaf 4)\002"
|
||||||
FG_MGN="$(tput setaf 5)"
|
FG_MGN="\001$(tput setaf 5)\002"
|
||||||
FG_CYN="$(tput setaf 6)"
|
FG_CYN="\001$(tput setaf 6)\002"
|
||||||
FG_WHT="$(tput setaf 7)"
|
FG_WHT="\001$(tput setaf 7)\002"
|
||||||
FG_DEF="$(tput setaf 9)"
|
FG_DEF="\001$(tput setaf 9)\002"
|
||||||
|
|
||||||
BG_BLK="$(tput setab 0)"
|
BG_BLK="\001$(tput setab 0)\002"
|
||||||
BG_RED="$(tput setab 1)"
|
BG_RED="\001$(tput setab 1)\002"
|
||||||
BG_GRN="$(tput setab 2)"
|
BG_GRN="\001$(tput setab 2)\002"
|
||||||
BG_YEL="$(tput setab 3)"
|
BG_YEL="\001$(tput setab 3)\002"
|
||||||
BG_BLU="$(tput setab 4)"
|
BG_BLU="\001$(tput setab 4)\002"
|
||||||
BG_MGN="$(tput setab 5)"
|
BG_MGN="\001$(tput setab 5)\002"
|
||||||
BG_CYN="$(tput setab 6)"
|
BG_CYN="\001$(tput setab 6)\002"
|
||||||
BG_WHT="$(tput setab 7)"
|
BG_WHT="\001$(tput setab 7)\002"
|
||||||
BG_DEF="$(tput setab 9)"
|
BG_DEF="\001$(tput setab 9)\002"
|
||||||
|
|
||||||
BOLD="$(tput bold)"
|
BOLD="\001$(tput bold)\002"
|
||||||
|
|
||||||
RST=$(tput sgr0)
|
RST="\001$(tput sgr0)\002"
|
||||||
|
|
||||||
git_root() {
|
git_root() {
|
||||||
git rev-parse --show-toplevel 2> /dev/null
|
git rev-parse --show-toplevel 2> /dev/null
|
||||||
@@ -42,16 +42,12 @@ git_root() {
|
|||||||
prompt_function() {
|
prompt_function() {
|
||||||
prompt=""
|
prompt=""
|
||||||
|
|
||||||
HOST_COLOR_ID=$(( "16#$(echo tls-proxy | md5sum | cut -f1 -d' ')" % 7 + 1)) # [1, 7]
|
HOST_COLOR_ID=$(( "16#$(hostname | md5sum | cut -f1 -d' ')" % 7 + 1)) # [1, 7]
|
||||||
HOST_COLOR="${RST}$(tput setaf $HOST_COLOR_ID)"
|
HOST_COLOR="${RST}\001$(tput setaf $HOST_COLOR_ID)\002"
|
||||||
GIT_COLOR="${RST}${FG_CYN}"
|
GIT_COLOR="${RST}${FG_CYN}"
|
||||||
DIR_COLOR="${RST}${FG_YEL}"
|
DIR_COLOR="${RST}${FG_YEL}"
|
||||||
WARN_COLOR="${RST}${BOLD}${FG_RED}"
|
WARN_COLOR="${RST}${BOLD}${FG_RED}"
|
||||||
|
|
||||||
if [[ $INSIDE_EMACS ]]; then
|
|
||||||
prompt+=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$(whoami)" == root ]]; then
|
if [[ "$(whoami)" == root ]]; then
|
||||||
prompt+="${WARN_COLOR}"
|
prompt+="${WARN_COLOR}"
|
||||||
else
|
else
|
||||||
@@ -75,12 +71,11 @@ prompt_function() {
|
|||||||
prompt+="${DIR_COLOR}[$(dirs)]${RST}"
|
prompt+="${DIR_COLOR}[$(dirs)]${RST}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$prompt\$ "
|
printf "$prompt\$ "
|
||||||
}
|
}
|
||||||
|
|
||||||
PS1="\$(prompt_function)"
|
PS1="\$(prompt_function)"
|
||||||
|
|
||||||
|
|
||||||
if [[ -z "$INSIDE_EMACS" ]]; then
|
if [[ -z "$INSIDE_EMACS" ]]; then
|
||||||
EMACS="emacsclient -a="" -c"
|
EMACS="emacsclient -a="" -c"
|
||||||
alias emacs="$EMACS"
|
alias emacs="$EMACS"
|
||||||
|
|||||||
Reference in New Issue
Block a user