diff --git a/src/vte.sh b/src/vte.sh
index 2d211ca..ce12113 100644
--- a/src/vte.sh
+++ b/src/vte.sh
@@ -57,8 +57,12 @@ __vte_prompt_command() {
 
 case "$TERM" in
   xterm*|vte*)
-    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
-    [ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
+    if [ -n "$BASH_VERSION" -a "${PROMPT_COMMAND#*__vte_prompt_command}" = "$PROMPT_COMMAND" ]; then
+      PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }__vte_prompt_command"
+    fi
+    if [ -n "$ZSH_VERSION" -a "${precmd_functions[*]#*__vte_osc7}" = "${precmd_functions[*]}" ]; then
+      precmd_functions+=(__vte_osc7)
+    fi
     ;;
 esac
 
