Navigation

Operators and Keywords

Function List:

C++ API

: val = PS1 ()
: old_val = PS1 (new_val)
: PS1 (new_val, "local")

Query or set the primary prompt string.

When executing interactively, Octave displays the primary prompt when it is ready to read a command.

The default value of the primary prompt string is "octave:\#> ". To change it, use a command like

PS1 ("\\u@\\H> ")

which will result in the prompt ‘boris@kremvax> ’ for the user ‘boris’ logged in on the host ‘kremvax.kgb.su’. Note that two backslashes are required to enter a backslash into a double-quoted character string. See ‘Strings’.

You can also use ANSI escape sequences if your terminal supports them. This can be useful for coloring the prompt. For example,

PS1 ('\[\033[01;31m\]\s:\#> \[\033[0m\]')

will give the default Octave prompt a red coloring.

When called from inside a function with the "local" option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

See also: PS2, PS4.

Package: octave