Hi again @Tilda.
IMHO the plugin code needs to take into account the startup.m
. In my “vast” experience (I have talked to only one other person about Matlab startup!) startup.m
is used by many people … apart the joke on the vast experience, it is a sensible thing that the plugin code takes startup.m
into account.
One of the things that the startup may do is to change the initial Matlab directory, and I do not know whether the -sd
switch supersedes that, as I have Matlab R2011b which does not support it so I can’t test it (my guess is that it does not, I assume that startup is run after -sd
fixes the directory).
Moreover, I feel that users would like to start from the directory that they defined in the startup.
My proposed tm_matlab
is therefore
#!/bin/bash
echo -ne "\002verbatim:"
PLUGIN_CODE_PATH=$TEXMACS_PATH/plugins/matlab/code/
export MATLAB_BASH=/Applications/MATLAB_R2020a.app/bin/
export MATLABPATH="$MATLABPATH:$MATLAB_BASH:$PLUGIN_CODE_PATH"
matlab -nodesktop -nosplash -r tmrepl
where
- I have added the PLUGIN_CODE_PATH to the MATLABPATH (recursively, so that if the user already has a MATLABPATH, we add to it)
- I have exported the MATLABPATH, so that the
matlab
process will see it (as far as I understand, you have to export environment variables so that child processes (I hope this is the correct expression) can see them.
Besides this, I did not understand what the MATLAB_BASH
variable does, I have therefore left it there.
Finally, for invoking Matlab commands which include slashes, you can include them in quotes. An example is
matlab -nodesktop -nosplash -r "addpath(fullfile(getenv('TEXMACS_PATH'),'plugins/matlab/code')); tmrepl"
which I did not use in the script because I liked the one with MATLABPATH
better .
Pls. let me know if this looks sensible.
Giovanni