View previous topic :: View next topic |
Author |
Message |
orion777 Apprentice
Joined: 15 Mar 2017 Posts: 207 Location: Riga, Latvia
|
Posted: Thu Jan 19, 2023 10:39 am Post subject: One click open .m file in the octave GUI editor |
|
|
Hallo to everyone!
I'm using xfce 4.16 and octave 7.3.0-r2.
I would like to open the *.m files in the octave GUI interface by simply clicking on the *.m file.
I have tried:
octave --gui in the file open menu - but this cause m file code to run and then exit (no GUI appears)
octave --gui --persist in the file open menu - then, when I'm clicking on the *.m file, the file runs, the results (figures) opens and stay opened, the GUI opens too, but the GUI contains no *.m file code in the editor (the GUI editor remains empty).
I'm mostly working with a MATLAB on Windows computers; typically I'm starting the MATLAB by clicking onto the *.m files (these, typically, are on USB drives); I'm not starting the MATLAB first, and then searching the file through the matlab's explorer... |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Thu Jan 19, 2023 1:46 pm Post subject: |
|
|
'octave --help' prints:
Code: | ...
Usage: octave [options] [FILE]
...
FILE Execute commands from FILE. Exit when done
unless --persist is also specified.
|
You could use option '--eval'. The command below opens a file in Octave's editor:
Code: | octave --gui --persist --eval "edit /usr/share/octave/7.3.0/etc/tests/fixed/publish/test_script_example.m" |
You could also open Octave and use drag&drop from Thunar (or a similar file manager) to open files in Octave's editor. |
|
Back to top |
|
|
orion777 Apprentice
Joined: 15 Mar 2017 Posts: 207 Location: Riga, Latvia
|
Posted: Fri Jan 20, 2023 6:13 am Post subject: |
|
|
Thanks for the answer!
However, I still can't do what I want.
I would like to open any *.m file by double click on it (in the xfce environment).
If I press mouse right button, then
Open with then
Open with another application,
where in the field Use a custom command I enter /usr/bin/octave --gui --persist --eval
the double click on the *.m file opens the octave in the GUI mode, but the octave by itself returns an error in the Command Window
Code: | error: parse error:
syntax error
>>> /home/user/Desktop/hexa.m
^
>> |
|
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Fri Jan 20, 2023 1:53 pm Post subject: |
|
|
Create a file ~/bin/octave_edit with the contents below:
Code: | #!/bin/sh
octave --gui --persist --eval "edit '$1'" |
Make it executable:
Code: | chmod u+x ~/bin/octave_edit |
Open Thunar, right click on a .m file, select 'open with', 'set default file' and select the script you created: 'octave_edit'. Don't forget to enable "Use as default for this kind of file". |
|
Back to top |
|
|
orion777 Apprentice
Joined: 15 Mar 2017 Posts: 207 Location: Riga, Latvia
|
Posted: Fri Jan 20, 2023 3:07 pm Post subject: |
|
|
Yes, it works! Thanx a lot!! |
|
Back to top |
|
|
|