On notebook edit, save, or opening I'd like to call SetDirectory[NotebookDirectory[]]
.
Using this excellent answer, I tried the obvious:
i = 0; SetOptions[$FrontEndSession,
FrontEndDynamicExpression :> Refresh[Notebooks[];
If[CurrentValue[EvaluationNotebook[], {"NotebookFileName"}] != "",
SetDirectory[NotebookDirectory[]];
Print["Switching to notebook's directory", ++i]],
TrackedSymbols :> {}]]
But this doesn't seem to work.
$Pre
to check/set on every evaluation. I prefer to keep it simple and putSetDirectory[NotebookDirectory[]];
before any code that depends on the path being set. $\endgroup$