Commit 441b67e2 authored by Dreamcat4's avatar Dreamcat4
Browse files

vte.sh: improvement - simple hook function to preserve user custom prompts

parent f95c35b9
......@@ -57,7 +57,29 @@ __vte_prompt_command() {
case "$TERM" in
xterm*|vte*)
[ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
if [ -n "$BASH_VERSION" ]; then
# if the user has already set a custom PS1 prompt, via PROMPT_COMMAND
if [ -n "$PROMPT_COMMAND" ] && [ "$PROMPT_COMMAND" != "__vte_prompt_command_custom" ]; then
export _vte_prompt_command_user="$PROMPT_COMMAND"
# then define a vte hook function, to carry / persist the vte prompt information
__vte_prompt_command_custom() {
# first run the user's custom prompt function
$_vte_prompt_command_user
# then inject vte function afterwards, appending it at the end of user's custom prompt
VTE_PWD_THING="\[$(__vte_osc7)\]"
PS1="${PS1}${VTE_PWD_THING}"
}
PROMPT_COMMAND="__vte_prompt_command_custom"
else
# the user has not set any custom prompt function yet, so call the vte prompt directly
PROMPT_COMMAND="__vte_prompt_command"
fi
fi
[ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7)
;;
esac
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment