Skip to content

Commit

Permalink
Fix rupa#262 by separating new PROMPT_COMMAND commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmanc authored Aug 22, 2019
1 parent 9d5a3fe commit 065ab44
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &);'
}
}
Expand Down

0 comments on commit 065ab44

Please sign in to comment.