winkmal
winkmal

Reputation: 632

How to change Octave working directory at startup?

It took me a lot of searching on Octave wiki, documentation etc., to finally find a way to change Octave working directory at startup; when typing system('set') at the Octave command prompt, it lists all environment variables, i.a. USERPROFILE=C:\Users\me. But I want the program to load C:\Users\me\Octave instead.

A possible solution consists in adding the following lines

setenv("USERPROFILE", "C:\\Users\\me\\Octave");
cd(getenv("USERPROFILE"));

to C:\Octave\Octave-4.0.3\share\octave\4.0.3\m\startup\octaverc.

However, this appears a bit clumpsy to me. It changes the environment variable USERPROFILE at each Octave startup and then tells the program to use it as the working directory. Isn't there a way to permanently change USERPROFILE, maybe on the Windows command line?

Upvotes: 4

Views: 19232

Answers (3)

Slubgob
Slubgob

Reputation: 11

In the current Octave GUI you can select Edit->Preferences and on the "General" tab at the bottom is an option to set your start up directory. Optionally you can just click the box to have it restart from that last used working directory.

Upvotes: 1

Malay Revanth
Malay Revanth

Reputation: 259

If you are using Octave Workbench, it's easy to change the directory using File Browser window by clicking on the wheel button and click "Set Browsing Directory", choose your respective directory and click ok. This changes your current directory. Can also be verified using pwd command.

Upvotes: 2

carandraug
carandraug

Reputation: 13091

Octave does not care where it starts and is not configured to start in any place. When you start Octave, its working directory will be whatever directory you were when you started it.

This makes a lot more sense when you do things in the command line which I guess is not your case. When you double click on an icon to start an application, like Octave, your system needs to start it somewhere. How to configure this will be system-dependent. Try right click on your the Octave icon, and in the properties menu look for something about configuring the start directory.

However, if your idea of how Octave should work is that it should always move to a specific directory, then I would use the .octaverc as you are now --- but I would just do cd ("..."), no need to set USERPROFILE. That will ensure that Octave always changes directory there, no matter how start Octave.

Upvotes: 8

Related Questions