4
$\begingroup$

Based on certain previous questions, I figured that if my NotebookBrowseDirectory looked like this

Options[$FrontEnd, NotebookBrowseDirectory]
{NotebookBrowseDirectory -> "/Users/brian/mma"}

then the OSX front end would default to saving new notebooks there. Instead it defaults to saving them in the home directory /Users/brian. Does there exist a variable I can set to make the UI default to saving into a different directory from my homedir?

$\endgroup$
5
  • $\begingroup$ SetDirectory[dir] sets the current working directory to dir $\endgroup$
    – acl
    Commented Dec 2, 2012 at 2:58
  • 2
    $\begingroup$ NotebookBrowseDirectory works on Windows and Linux, but on Mac, we allow the operating system to assert its natural behavior over such things. I'm not now so convinced that this was a good idea, but I haven't finished a proper investigation. So, it's possible this behavior will change in the future. $\endgroup$
    – John Fultz
    Commented Dec 2, 2012 at 8:22
  • $\begingroup$ @John Fultz I am glad that Mathematica integrates so nicely with OSX. In my opinion it is a elemental feature of OSX that usage of system wide GUI-logic is encouraged and that most programmes out there play within the 'rules'. Examples where custom interfaces are used (e.g. ditching the top menu bar of OSX - like Matlab does) turn out pretty bad in like 99% of the time and just ruin user experience. $\endgroup$
    – Sascha
    Commented Dec 2, 2012 at 10:39
  • $\begingroup$ So would an init.m with a SetDirectory[] command work to do more or less what I want? $\endgroup$
    – Brian B
    Commented Dec 2, 2012 at 20:23
  • $\begingroup$ No, what Nasser was suggesting was the opposite of what you're asking. Since the Kernel and FrontEnd are separate processes in the OS, each has its own notion of the "current directory". SetDirectory sets the current directory for the Kernel. NotebookBrowseDirectory would set this for the front end, but as John points out above the OSX FrontEnd currently ignores that. $\endgroup$ Commented Dec 4, 2012 at 4:13

1 Answer 1

3
$\begingroup$

On OS X (I'm using 10.9 and Mathematica 9) the file chooser dialogue will remember the last location you used.

So if you Save/Open something to/from /Users/brian/mma, then next time you bring up the file chooser it will show the same directory. This should be convenient.

Per John Fultz's comment above (from Dec 2 '12), it is not possible to set this location on OS X by changing CurrentValue[$FrontEnd, "NotebookBrowseDirectory"]. Quoting the comment:

NotebookBrowseDirectory works on Windows and Linux, but on Mac, we allow the operating system to assert its natural behavior over such things. I'm not now so convinced that this was a good idea, but I haven't finished a proper investigation. So, it's possible this behavior will change in the future.

$\endgroup$
6
  • $\begingroup$ "On OS X (I'm using 10.9 and Mathematica 9) the file chooser dialogue will remember the last location you used." — That would be great if it were true, but I am also using OS 10.9 and Mathematica 9 and I don't see that behavior at all. Every time I choose "Save as…" or "Open…", the dialog opens to my user folder (~/), regardless of the last location I used. Why don't I see the behavior you describe in this answer? $\endgroup$ Commented Oct 10, 2014 at 17:45
  • $\begingroup$ Or sometimes ~/Documents/. It's always consistent for a given notebook, but sometimes switches for different notebooks. $\endgroup$ Commented Oct 10, 2014 at 17:47
  • 1
    $\begingroup$ @thecommexokid I don't know. I tried it again and mine remembers, both with M9.0.1 and M10.0.1 on OS X 10.9.5. Try this, and restart M, though I don't know if it will help. $\endgroup$
    – Szabolcs
    Commented Oct 10, 2014 at 18:10
  • $\begingroup$ Your suggestion had no effect, alas, but I have better diagnosed the problem. The file-chooser will remember my last save/open location up to the granularity of the correct item in my Finder sidebar, but will not remember any sub-directories beyond that. So if I save to ~/Documents/a/ it reopens to ~/Documents/. If I save to ~/Downloads/a/b/c/ it reopens to ~/Downloads/. $\endgroup$ Commented Oct 10, 2014 at 18:31
  • $\begingroup$ The NotebookBrowseDirectory setting in Options for Global Preferences that you pointed me to in the suggestion you linked does get updated to the correct subdirectory each time, though! It's just not where the dialog actually opens to. $\endgroup$ Commented Oct 10, 2014 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.