A.8.2 Loadable Files
You can customize your Mathematica by adding files that can loaded into the system under different circumstances. Such files are conventionally placed in either system-wide or user-specific base directories.
Base directories for files to be loaded by Mathematica.
|$BaseDirectory ||system-wide base directory for files to be loaded by Mathematica |
|$UserBaseDirectory ||user-specific base directory for files to be loaded by Mathematica |
Typical values of $BaseDirectory.
|/Library/Mathematica ||Macintosh |
|/usr/share/Mathematica ||Unix |
Typical values of $UserBaseDirectory.
|~/Library/Mathematica ||Macintosh |
|~/.Mathematica ||Unix |
You can specify different locations for these directories by setting operating system environment variables when you launch Mathematica, as discussed in Section A.7.1.
Typical subdirectories of Mathematica base directories.
|Applications ||Mathematica application packages |
|Autoload ||packages to be autoloaded on startup |
|FrontEnd ||front end initialization files |
|Kernel ||kernel initialization files |
|Licensing ||license management files |
|SystemFiles ||general system files |
Some files in base directories serve as configuration files, automatically used by the Mathematica kernel or front end.
Some typical kernel and front end configuration files.
|Kernel/init.m ||run when the kernel is started |
|Kernel/end.m ||run when the kernel is terminated |
|FrontEnd/init.m ||read when the front end is started |
|customized notebook style sheets |
|SystemFiles/FrontEnd/Palettes/ ||additional palettes to appear in the front end menu |
Kernel configuration files can contain any Mathematica commands. These commands can test global variables such as $SystemID and $MachineName to determine what operations to perform. Front end configuration files can contain only certain special commands, as described in Section A.2.12.
Subdirectories under $BaseDirectory and $UserBaseDirectory.
|Applications/name/ ||named add-on applications |
|Autoload/name/ ||add-ons to be loaded automatically when Mathematica is started |
With the default setting for the kernel $Path variable, an add-on can be loaded from within a Mathematica session simply by using the command <<name`. This will load the init.m file for the add-on, which should in turn be set up to load other necessary files or packages.
By placing an add-on under the Autoload subdirectory of $BaseDirectory or $UserBaseDirectory, you can have Mathematica automatically load the add-on whenever you start the kernel or the front end.
Typical possible contents of the directory for an add-on.
|init.m or Kernel/init.m ||an initialization file to be loaded by the kernel |
|FrontEnd/init.m ||an initialization file to be loaded by the front end |
|Documentation/ ||documentation to be found by the front end |
Note that with the default setting for the front end documentation path, all documentation in Documentation directories will automatically show up in the front end Help Browser.