Repository: cantino/mcfly (language: rust)

Issue:
Conflict with zoxide

```sh
eval "$(mcfly init bash)"
eval "$(zoxide init bash)"
```

With these two tool enabled at the same time, when I open a new shell I get this:
`
bash: PROMPT_COMMAND: line 0: syntax error near unexpected token `;;'
bash: PROMPT_COMMAND: line 0: `mcfly_prompt_command;;__zoxide_hook'
`
Then, running mcfly:

`
thread 'main' panicked at 'McFly error: Please ensure that MCFLY_HISTORY is set (environment variable not found)', /net/homedirs/arusev/.cargo/registry/src/gitlab.spimageworks.com-dbbe1dfef02d8f03/mcfly-0.5.6/src/settings.rs:261:29
`

If I comment the `zoxide` line in my bashrc then it works. Any ideas which tool cases it?

Thanks.


Discussion / hints:
Hey @alexxbb. It looks like zoxide sets the PROMPT_COMMAND to `;__zoxide_hook` and mcfly then adds `mcfly_prompt_command;` at the front. I just tested and bash doesn't like the `;;` in the combined command.

Is it easy for you to run mcfly from source and see if https://github.com/cantino/mcfly/pull/160 fixes it for you?
Thanks @cantino, I will try to build from source tomorrow and let you know!
The fix is working but **only** if tools are sourced in this order:

    eval "$(zoxide init bash)"
    eval "$(mcfly init bash)"

If mcfly goes first, the error is the same.

Fix patch:
diff --git a/mcfly.bash b/mcfly.bash
index e529f06f..d2951e09 100644
--- a/mcfly.bash
+++ b/mcfly.bash
@@ -56,8 +56,13 @@ function mcfly_prompt_command {
   return ${exit_code} # Restore the original exit code by returning it.
 }
 
-# Set $PROMPT_COMMAND run mcfly_prompt_command and then any existing $PROMPT_COMMAND.
-PROMPT_COMMAND="mcfly_prompt_command;${PROMPT_COMMAND#;}"
+# Set $PROMPT_COMMAND run mcfly_prompt_command, preserving any existing $PROMPT_COMMAND.
+if [ -z "$PROMPT_COMMAND" ]
+then
+  PROMPT_COMMAND="mcfly_prompt_command"
+else
+  PROMPT_COMMAND="mcfly_prompt_command;${PROMPT_COMMAND#;}"
+fi
 
 # If this is an interactive shell, take ownership of ctrl-r.
 if [[ $- =~ .*i.* ]]; then


Test patch: