Created
October 1, 2018 23:28
-
-
Save grahamannett/4a56743ea4fb1b50110483abf4938097 to your computer and use it in GitHub Desktop.
matlab fish functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function matlab -w matlab -a cmd -d 'matlab fish shell function.' | |
# main executable | |
set -l MATLAB_APP /Applications/MATLAB_R2018a.app/bin/matlab | |
# help command | |
set -l PRINT_HELP """ | |
matlab [command] | |
use matlab from terminal | |
commands: | |
nodesktop - run with -nodisplay -nospash (default) | |
run - run a matlab program with -nodisplay -nospalsh -r [input_file] | |
desktop - run with desktop app $MATLAB_APP | |
other\* - run with whatever \$argv is | |
""" | |
if [ -z "$cmd" ]; # No arguments | |
eval $MATLAB_APP -nodisplay -nosplash | |
return | |
end | |
# various commands | |
switch "$cmd" | |
case help -h | |
echo $PRINT_HELP | |
case 'run' | |
# echo "running with -r using argv: $MATLAB_APP -nodisplay -nosplash -r $argv[2]" | |
eval $MATLAB_APP -nodisplay -nosplash -r $argv[2] | |
case 'nodesktop' | |
# echo "runing with $MATLAB_APP -nodisplay -nosplash" | |
eval $MATLAB_APP -nodisplay -nosplash | |
case 'desktop' | |
# echo "running desktop $MATLAB_APP" | |
eval $MATLAB_APP | |
case '*' | |
# echo "running: $MATLAB_APP $argv" | |
eval $MATLAB_APP $argv | |
end | |
end | |
complete -c matlab -a "run" -d "run file" | |
complete -c matlab -a "help" -d "get command help" -x | |
complete -c matlab -a "nodesktop" -d "run with nodisplay" -x | |
complete -c matlab -a "desktop" -d "run with desktop" -x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment