leoCCB
(usa Slackware)
Enviado em 20/05/2022 - 22:31h
Nicolas_SS escreveu:
O resultado do comando echo $TERM eh:
xterm-256color
Arquivo .bashrc do usuário.
############################################################################
#### CUSTOMIZAR BASH ####
## copie este cógigo e cole no final do seu arquivo *.bashrc* na sua home ##
bash_prompt_command() {
# How many characters of the $PWD should be kept
local pwdmaxlen=25
# Indicate that there has been dir truncation
local trunc_symbol=".."
# Store local dir
local dir=${PWD##*/}
# Which length to use
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
NEW_PWD=${PWD/#$HOME/\~}
#GIT_BRANCH="$(__git_ps1 " (%s)")"
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
# Generate name
if [ ${pwdoffset} -gt "0" ]
then
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/}
fi
}
format_font()
{
## FIRST ARGUMENT TO RETURN FORMAT STRING
local output=$1
case $# in
2)
eval $output="'\[\033[0;${2}m\]'"
;;
3)
eval $output="'\[\033[0;${2};${3}m\]'"
;;
4)
eval $output="'\[\033[0;${2};${3};${4}m\]'"
;;
*)
eval $output="'\[\033[0m\]'"
;;
esac
}
##
## COLORIZE BASH PROMT
##
bash_prompt() {
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
############################################################################
## COLOR CODES ##
## These can be used in the configuration below ##
############################################################################
## FONT EFFECT
local NONE='0'
local BOLD='1'
local DIM='2'
local UNDERLINE='4'
local BLINK='5'
local INVERT='7'
local HIDDEN='8'
## COLORS
local DEFAULT='9'
local BLACK='0'
local RED='1'
local GREEN='2'
local YELLOW='3'
local BLUE='4'
local MAGENTA='5'
local CYAN='6'
local L_GRAY='7'
local D_GRAY='60'
local L_RED='61'
local L_GREEN='62'
local L_YELLOW='63'
local L_BLUE='64'
local L_MAGENTA='65'
local L_CYAN='66'
local WHITE='67'
## TYPE
local RESET='0'
local EFFECT='0'
local COLOR='30'
local BG='40'
## 256 COLOR CODES
local NO_FORMAT="\[\033[0m\]"
local ORANGE_BOLD="\[\033[1;38;5;208m\]"
local TOXIC_GREEN_BOLD="\[\033[1;38;5;118m\]"
local RED_BOLD="\[\033[1;38;5;1m\]"
local CYAN_BOLD="\[\033[1;38;5;87m\]"
local BLACK_BOLD="\[\033[1;38;5;0m\]"
local WHITE_BOLD="\[\033[1;38;5;15m\]"
local GRAY_BOLD="\[\033[1;90m\]"
local BLUE_BOLD="\[\033[1;38;5;74m\]"
############################################################################
## CONFIGURATION ##
## Escolha sua configuração de cores aqui ##
############################################################################
## DEFAUT
FONT_COLOR_1=$WHITE; BACKGROUND_1=$BLUE; TEXTEFFECT_1=$BOLD
FONT_COLOR_2=$WHITE; BACKGROUND_2=$L_BLUE; TEXTEFFECT_2=$BOLD
FONT_COLOR_3=$D_GRAY; BACKGROUND_3=$WHITE; TEXTEFFECT_3=$BOLD
PROMT_FORMAT=$BLUE_BOLD
############################################################################
## TEXT FORMATING ##
## Generate the text formating according to configuration ##
############################################################################
## CONVERT CODES: add offset
FC1=$(($FONT_COLOR_1+$COLOR))
BG1=$(($BACKGROUND_1+$BG))
FE1=$(($TEXTEFFECT_1+$EFFECT))
FC2=$(($FONT_COLOR_2+$COLOR))
BG2=$(($BACKGROUND_2+$BG))
FE2=$(($TEXTEFFECT_2+$EFFECT))
FC3=$(($FONT_COLOR_3+$COLOR))
BG3=$(($BACKGROUND_3+$BG))
FE3=$(($TEXTEFFECT_3+$EFFECT))
FC4=$(($FONT_COLOR_4+$COLOR))
BG4=$(($BACKGROUND_4+$BG))
FE4=$(($TEXTEFFECT_4+$EFFECT))
## CALL FORMATING HELPER FUNCTION: effect + font color + BG color
local TEXT_FORMAT_1
local TEXT_FORMAT_2
local TEXT_FORMAT_3
local TEXT_FORMAT_4
format_font TEXT_FORMAT_1 $FE1 $FC1 $BG1
format_font TEXT_FORMAT_2 $FE2 $FC2 $BG2
format_font TEXT_FORMAT_3 $FC3 $FE3 $BG3
format_font TEXT_FORMAT_4 $FC4 $FE4 $BG4
# GENERATE PROMT SECTIONS
local PROMT_USER=$"$TEXT_FORMAT_1 \u "
local PROMT_HOST=$"$TEXT_FORMAT_2 \h "
local PROMT_PWD=$"$TEXT_FORMAT_3 \${NEW_PWD} \${GIT_BRANCH} "
local PROMT_INPUT=$"$PROMT_FORMAT "
############################################################################
## SEPARATOR FORMATING ##
## Generate the separators between sections ##
## Uses background colors of the sections ##
############################################################################
## CONVERT CODES
TSFC1=$(($BACKGROUND_1+$COLOR))
TSBG1=$(($BACKGROUND_2+$BG))
TSFC2=$(($BACKGROUND_2+$COLOR))
TSBG2=$(($BACKGROUND_3+$BG))
TSFC3=$(($BACKGROUND_3+$COLOR))
TSBG3=$(($DEFAULT+$BG))
## CALL FORMATING HELPER FUNCTION: effect + font color + BG color
local SEPARATOR_FORMAT_1
local SEPARATOR_FORMAT_2
local SEPARATOR_FORMAT_3
format_font SEPARATOR_FORMAT_1 $TSFC1 $TSBG1
format_font SEPARATOR_FORMAT_2 $TSFC2 $TSBG2
format_font SEPARATOR_FORMAT_3 $TSFC3 $TSBG3
## GENERATE SEPARATORS WITH FANCY TRIANGLE
#local TRIANGLE=$'🐷 '
#local TRIANGLE=$'\uE0B0'
local SEPARATOR_1=$SEPARATOR_FORMAT_1$TRIANGLE
local SEPARATOR_2=$SEPARATOR_FORMAT_2$TRIANGLE
local SEPARATOR_3=$SEPARATOR_FORMAT_3$TRIANGLE
############################################################################
## WINDOW TITLE ##
## Prevent messed up terminal-window titles ##
############################################################################
case $TERM in
xterm*|rxvt*)
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
;;
*)
local TITLEBAR=""
;;
esac
############################################################################
## BASH PROMT ##
## Generate promt and remove format from the rest ##
############################################################################
PS1="$TITLEBAR\n${PROMT_USER}${SEPARATOR_1}${PROMT_HOST}${SEPARATOR_2}${PROMT_PWD}${SEPARATOR_3}${PROMT_INPUT}"
## For terminal line coloring, leaving the rest standard
none="$(tput sgr0)"
trap 'echo -ne "${none}"' DEBUG
}
################################################################################
## MAIN ##
################################################################################
## Bash provides an environment variable called PROMPT_COMMAND.
## The contents of this variable are executed as a regular Bash command
## just before Bash displays a prompt.
## We want it to call our own command to truncate PWD and store it in NEW_PWD
PROMPT_COMMAND=bash_prompt_command
## Call bash_promnt only once, then unset it (not needed any more)
## It will set $PS1 with colors and relative to $NEW_PWD,
## which gets updated by $PROMT_COMMAND on behalf of the terminal
bash_prompt
unset bash_prompt
alias ls='ls --color=auto'
LS_COLORS='no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
export LS_COLORS
comenta essa linha
# xterm*|rxvt*)
e coloca direto o xterm-256color
deixando o bloco assim:
case $TERM in
# xterm*|rxvt*)
xterm-256color)
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]'
e também reinstalar o xterm... pode ser q resolva.
Cara, onde vc arrumou esse script? Tá bem escrito pra caramba!! Não entendo quase nada de Shell, mas pelo pouco q entendo percebo q o programador soube escolher os comandos mais rápidos aí!! Outra coisa q eu tentaria seria colocar a dupla de dois pontos no fim das linhas e não na próxima, embora funcione bem nos blocos acima... não custa tentar, e ficariam com essa carinha aqui
case $TERM in
# xterm*|rxvt*)
xterm-256color)
local TITLEBAR='\[\033]0;\u:${NEW_PWD}\007\]' ;;
*) local TITLEBAR="" ;;
esac