Repository: cantino/mcfly (language: rust)

Issue:
Fish’s private mode
The question is simple: should McFly automatically respect Fish’s private mode? Because, at this point, it doesn’t, so anything you type in private mode goes to MyFly’s database, while Fish’s history stays clear of it.

The fix is simple since there’s an environment variable for that. Yet an emphasis here is on automatically. Should a user consciously decide to forbid and manually implement it in the config, or should it be enabled by default?

I’ll gladly implement the default option if the community agrees to it.


Discussion / hints:
I wasn't aware of Fish's private mode. That's a great question. If fish's history avoids recording commands in private mode, we probably should too. I'd be glad to accept a PR.
Got it. I’ll get to it then 👍

Fix patch:
diff --git a/mcfly.fish b/mcfly.fish
index 7fe5a584..1d0ee9b6 100644
--- a/mcfly.fish
+++ b/mcfly.fish
@@ -31,7 +31,9 @@ if test "$__MCFLY_LOADED" != "loaded"
   end
 
   function __mcfly_add_command -d 'Add run commands to McFly database' -e fish_postexec
-    # First, retain return code of last command before we lose it
+    # Check for the private mode
+    test -n "$fish_private_mode"; and return
+    # Retain return code of last command before we lose it
     set -l last_status $status
     # Handle first call of this function after sourcing mcfly.fish, when the old PWD won't be set
     set -q __MCFLY_OLD_PWD; or set -g __MCFLY_OLD_PWD "$PWD"


Test patch: