From 065ab44ac4eaa42fd12abc224d78e8fd7efb9171 Mon Sep 17 00:00:00 2001 From: Mark Crossfield Date: Thu, 22 Aug 2019 14:07:43 +0100 Subject: [PATCH] Fix #262 by separating new PROMPT_COMMAND commands --- z.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/z.sh b/z.sh index c78f3cb..957bfe5 100644 --- a/z.sh +++ b/z.sh @@ -247,6 +247,11 @@ elif type complete >/dev/null 2>&1; then [ "$_Z_NO_PROMPT_COMMAND" ] || { # populate directory list. avoid clobbering other PROMPT_COMMANDs. grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || { + # Check if there are existing PROMPT_COMMANDs that are not terminated with a semicolon + if [[ "$PROMPT_COMMAND" =~ ^[^\ ]+ ]] && ! [[ "$PROMPT_COMMAND" =~ ^.*\;\ *$ ]] + then # terminate it + PROMPT_COMMAND="$PROMPT_COMMAND; " + fi PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &);' } }