Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
One click open .m file in the octave GUI editor
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
orion777
Apprentice
Apprentice


Joined: 15 Mar 2017
Posts: 207
Location: Riga, Latvia

PostPosted: Thu Jan 19, 2023 10:39 am    Post subject: One click open .m file in the octave GUI editor Reply with quote

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
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Thu Jan 19, 2023 1:46 pm    Post subject: Reply with quote

'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
View user's profile Send private message
orion777
Apprentice
Apprentice


Joined: 15 Mar 2017
Posts: 207
Location: Riga, Latvia

PostPosted: Fri Jan 20, 2023 6:13 am    Post subject: Reply with quote

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
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Fri Jan 20, 2023 1:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
orion777
Apprentice
Apprentice


Joined: 15 Mar 2017
Posts: 207
Location: Riga, Latvia

PostPosted: Fri Jan 20, 2023 3:07 pm    Post subject: Reply with quote

Yes, it works! Thanx a lot!!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum