我将 shell 脚本用于某些特定目的,它的功能是 relad .bash_profile
:
function refresh {
source "$HOME/.bash_profile"
}
同样.bash_profile
有这样的说法:
if [ -f "$HOME/.bash_prompt" ]; then
source "$HOME/.bash_prompt"
fi
哪个也应该重新加载.bash_prompt
;确实如此,该提示文件包含应该更改提示显示的值(颜色、文本位置等),但这些值不会改变。它们仅在新的终端窗口或我source "$HOME/.bash_prompt"
在终端窗口内显式调用时才会更改。
我在这里做错了吗?
这是我的.bash_prompt
来源:
# Colors
# Bunch of color codes
function print_before_the_prompt {
# create a $fill of all screen width
let fillsize=${COLUMNS}
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
printf "$txtrst$bakwht%s" "$fill"
printf "\n$bldblk%s%s\n" "${PWD/$HOME/~}" "$(__git_ps1 "$txtrst [$txtblu%s$txtrst]")"
}
# Load Git completion and prompt
if [ -f "/usr/local/opt/git/etc/bash_completion.d/git-completion.bash" ]; then
source "/usr/local/opt/git/etc/bash_completion.d/git-completion.bash"
fi
if [ -f "/usr/local/opt/git/etc/bash_completion.d/git-prompt.sh" ]; then
source "/usr/local/opt/git/etc/bash_completion.d/git-prompt.sh"
fi
GIT_PS1_SHOWDIRTYSTATE=true
PROMPT_COMMAND=print_before_the_prompt
PS1="\[$txtred\]⦿\[$txtrst\] "