Alex Rivera | Logout

Init.m considerations and good practices

Asked 2011-03-13T23:02:58.417
10

As I never found (or perhaps I never search for it enough) a good article about how to manage the init.m files, I ended up developing my own "standard", but I wonder how bad I did it.

For example, my usual init.m is stored in C:\Documents and Settings\All Users\Application Data\Mathematica\Kernel\init.m (Windows) and I edit it using a text editor.

As I don't want the definitions to go into the Global context, the content is something like:

(** User Mathematica initialization file **)
Begin["MyInitContext`"];

Cl:=Clear["Global`*"];
(* Other definitions in this Context *)

End[]; (* End Context *)
$ContextPath = Prepend[$ContextPath,"MyInitContext`"];

I don't load packages from the init.m, because I want strict control over what I load, so I only define here shortcuts to utility functions I use on a daily basis and some options.

So: Any references to good practices? Better ways to achieve this kind of behavior? Any caveats?

Edit
Report

1 Answer

5

Having also not followed an official doctrine, I can only tell you what I do.

My Kernel/init.m contains no functions itself. I use it to:

  • Set certain options: $HistoryLength SetDirectory etc.
  • Do a little cleanup (I prefer not to start with a blank notebook)
  • Set my desired DeclarePackage calls
  • Load my custom functions package
answered 2011-03-14T01:21:06.693

Your Answer