Skip to content

Instantly share code, notes, and snippets.

@grahamannett
Created October 1, 2018 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamannett/4a56743ea4fb1b50110483abf4938097 to your computer and use it in GitHub Desktop.
Save grahamannett/4a56743ea4fb1b50110483abf4938097 to your computer and use it in GitHub Desktop.
matlab fish functions
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