I am just starting with Octave and running it on my terminal so far.
Everytime I open the prompt, my command line starts with :
octave-3.4.0:1>
So I use the following to make it shorter and easier to read:
PS1('>> ')
How can I change my settings to exectute this code automatically everytime I open octave?
How top of this, is there a way to change my terminal settings to open Octave when I enter 'Octave'? The way I do it now is by using
'exec 'path/to/octave/
Thanks
You can create edit ~/.octaverc
file that contains all the commands you want to execute when Octave starts up. This file is exactly like a .m
Octave script file.
Just add PS1('>> ')
to your ~/.octaverc
file. You can use your favorite text editor or use echo
on the command line:
$ echo "PS1('>> ')" >> ~/.octaverc
After that you can see the ~/.octaverc
file :
$ more ~/.octaverc
It should contain the following line :
PS1('>> ')
For the second question, I am not sure if you're on OSX or Ubuntu or something else. If octave
is in your search-path then you should be able to start Octave by just trying octave
. Try these commands to find out what octave
points to
$ which octave
/usr/bin/octave
$ type octave
octave is /usr/bin/octave
If somehow, octave
is not your PATH
search-path, this could be because you installed Octave at a non-standard location. You can do one of two things:
Add the folder containing your Octave executable to your PATH
search-path. In bash
, you can do this by adding the following line to your ~/.bashrc
(or ~/.profile
on MacOSX):
export PATH=~/path/to/octave/folder:${PATH}
You can create a soft symlink to your octave executable.
ln -s /path/to/octave/executable octave
This will create a symlink in your current folder. Now, as long as you're in the current folder, you'll be able to type in octave
and run Octave. If you want to be able to run Octave from anywhere (and not necessarily the current folder), you need to add the current folder to your search-path (see point 1 above).
Consider using the latest release which is GNU Octave 3.8 . It comes with a nice GUI if you're familiar with MATLAB.
You can customize the PS1 and any other settings on your ~/.octaverc
. Please read the documentation on startup files: http://www.gnu.org/software/octave/doc/interpreter/Startup-Files.html
As for calling Octave from anywhere, you need to set the PATH
variable in your shell to append the directory where Octave is installed, for instace in Bash:
export PATH=$PATH:/path/to/octave-3.8/bin
Start GNU Octave with option --traditional
( but I'm not sure if this was already implemented in 3.4.x ).
$ octave --traditional
GNU Octave, version 3.8.1
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.
Octave was configured for "x86_64-unknown-linux-gnu".
Additional information about Octave is available at http://www.octave.org.
Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html
Read http://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.
>> version
ans = 3.8.1
>>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.