Previous: Command Line Options, Up: Invoking Octave from the Command Line [Contents][Index]

#### 2.1.2 Startup Files

When Octave starts, it looks for commands to execute from the files in the following list. These files may contain any valid Octave commands, including function definitions.

`octave-home/share/octave/site/m/startup/octaverc` ¶

  where `octave-home` is the directory in which Octave is installed (the default is `/usr/local`). This file is provided so that changes to the default Octave environment can be made globally for all users at your site for all versions of Octave you have installed. Care should be taken when making changes to this file since all users of Octave at your site will be affected. The default file may be overridden by the environment variable `OCTAVE_SITE_INITFILE`.

`octave-home/share/octave/version/m/startup/octaverc` ¶

  where `octave-home` is the directory in which Octave is installed (the default is `/usr/local`), and `version` is the version number of Octave. This file is provided so that changes to the default Octave environment can be made globally for all users of a particular version of Octave. Care should be taken when making changes to this file since all users of Octave at your site will be affected. The default file may be overridden by the environment variable `OCTAVE_VERSION_INITFILE`.

`config-dir/octave/octaverc` ¶

  where `config-dir` is the platform-dependent location for user local configuration files (e.g., `$XDG_CONFIG_HOME` on many Unix-like operating systems or `%APPDATA%` on Windows).

`~/.octaverc` ¶

  This file is used to make personal changes to the default Octave environment.

`.octaverc` ¶

  This file can be used to make changes to the default Octave environment for a particular project. Octave searches for this file in the current directory after it reads `~/.octaverc`. Any use of the `cd` command in the `~/.octaverc` file will affect the directory where Octave searches for `.octaverc`.

  If you start Octave in your home directory, commands from the file `~/.octaverc` will only be executed once.

`startup.m` ¶

  This file is used to make personal changes to the default Octave environment. It is executed for MATLAB compatibility, but `~/.octaverc` is the preferred location for configuration changes.

A message will be displayed as each of the startup files is read if you invoke Octave with the `--verbose` option but without the `--silent` option.

The startup files are always processed in the system’s locale charset (independent of the m-file encoding that is set, for example, in the GUI properties). In other words, the system’s locale charset is in effect until a user manually sets the m-file encoding (e.g., in one of the startup files) and triggers re-parsing of any relevant m-files. Octave can be forced to use a new encoding with the undocumented function `__mfile_encoding__`:

    __mfile_encoding__ ("utf-8");  # set new encoding
    clear ("functions");  # re-parse all .m files in the new encoding

This changes the encoding that is used to interpret all subsequently run startup and m-files (not including the currently executing file).

Previous: Command Line Options, Up: Invoking Octave from the Command Line [Contents][Index]