I have tried figuring out how to programmatically edit the init.m notebooks with like NotebookWrite or NotebookPut but I haven’t figured it out so far. If anyone else knows how I could make this into a program that could be run in one iteration please comment.
I would like to mention that this only works if you have administrator privileges to access ProgramData. I tried running the program on a university computer as a student and I got a $Failed message.
I added another function to the button that creates vector maps by default:
Button["Set unit system to SI and make vector maps by default",
userBaseDirectoryStream =
OpenAppend[FileNameJoin[{$UserBaseDirectory, "Kernel", "init.m"}]];
WriteLine[userBaseDirectoryStream,
"$UnitSystem=\"Metric\";GeoGraphics`$GeoBackgroundType = \
\"Vector\";"];
Close[userBaseDirectoryStream];
BaseDirectoryStream =
OpenAppend[FileNameJoin[{$BaseDirectory, "Kernel", "init.m"}]];
WriteLine[BaseDirectoryStream,
"$UnitSystem=\"Metric\";GeoGraphics`$GeoBackgroundType = \
\"Vector\";"];
Close[BaseDirectoryStream];]
Is there a way to specify that the Option Inspector should autosave every time a computation is evaluated and when I close a notebook as a global preference with the init.m file by writing a line like $AutosaveDefault=True or something? I would like to use to compile a program that will store the configuration I like to use for Mathematica so I can’t easily transfer my preferences between computers.
An easy way to do this is using an external editor and editing manually that file. On Macs it is in the directory /Users/yourusername/Library/Mathematica/Kernel/. You can find the directory in your system with Mathematica itself using:
FileNameJoin[{$UserBaseDirectory, "Kernel"}]
there you have your user init.m file. You can edit it with a text editor, no Word!, and write in the commands you want for ALL your Notebooks be pre-executed
I have just put
SetOptions[Plot, ImageSize -> Full]
as I want all my plots large and resizable by default