Here's a little "one-liner" I've aliased to change the current directory in MATLAB to the current directory of a bash script in terminal. It uses applescript to send the cd
command to matlab.
osascript -e "`echo -e \"tell application \\"MATLAB_R2013b\\"\ndelay 0.1\nactivate\ntell application \\"System Events\\"\n keystroke \\" cd $(pwd)\\"\nkeystroke return\nend tell\nend tell\"`"
You may need to fiddle with the delays on your machine.
I alias this to cdmatlab
by playing this at the bottom of my ~/.profile
:
alias cdmatlab='osascript -e "`echo -e \"tell application \\"MATLAB_R2013b\\"\ndelay 0.1\nactivate\ntell application \\"System Events\\"\n keystroke \\" cd $(pwd)\\"\nkeystroke return\nend tell\nend tell\"`"'