Eu colocaria algo semelhante ao seguinte código no .bashrc, sem exigir que outros arquivos sejam abertos e gravados sempre que você pressionar a tecla Enter
SEP=("/" "/")
SEP_COLOR=("\e[0;34m" "\e[0;32m") #colors for: (FIXED - DEFAULT) SEPARATOR STRING
DIR_COLOR=("\e[0;32m" "\e[0;31m") #colors for: (FIXED - DEFAULT) DIR NAMES
CLOSE_COLOR="\e[0m"
FIXED_DIR=" /var/www/html"
FIXED_DIR=$(realpath ${FIXED_DIR})
FIXED_DIR_ARRAY=()
DIR=${FIXED_DIR}
while [[ "$DIR" != "/" ]]; do
B=$(basename -z $DIR)
DIR=$(dirname -z $DIR)
FIXED_DIR_ARRAY+=($B)
done
set_PS1 (){
local DIR=$PWD
local CUR_DIR_ARRAY=()
while : ; do
local B=$(basename -z $DIR)
local DIR=$(dirname -z $DIR)
CUR_DIR_ARRAY+=($B)
[[ "$DIR" == "/" ]] && break
done
local SELECTOR=0
local STR=""
local i=1
while [[ "$i" -le "${#CUR_DIR_ARRAY[@]}" ]] ; do
if [ -n $SELECTOR ] &&
[ $i -gt ${#FIXED_DIR_ARRAY[@]} ] ||
[ "${CUR_DIR_ARRAY[-$i]}" != "${FIXED_DIR_ARRAY[-$i]}" ];
then
SELECTOR=1
fi
local x=$(($SELECTOR%2));
STR+="${SEP_COLOR[$x]}${SEP[$x]}"
[[ "${CUR_DIR_ARRAY[-$i]}" != "${SEP[$x]}" ]] && STR+="${DIR_COLOR[$x]}${CUR_DIR_ARRAY[-$i]}"
STR+="${CLOSE_COLOR}"
((i++))
done
printf "${STR}"
}
PS1="[ \u@\h:/ -> \[\$(set_PS1)\] ] "