'Run octave-cli in vscode terminal

I am a Windows user, I want to use octave in the terminal of vscode.
I have put octave to the environment variable, but when I type octave in the terminal, it pop out the gui version.
I have tried to type octave --no-gui, it pop out the octave-cli window (Please refer to the image attached).
enter image description here Here are the questions:

  1. How can I use octave-cli in the terminal of vscode?
  2. Can I disable octave use gui when I type octave or I can only type octave --no-gui to use cli version?


Solution 1:[1]

In addition to the octave.vbs file that most people use to start octave, there is also an octave.bat file located under %OCTAVE-HOME%/mingw64/bin.

I'm not familiar with vscode, but if I open a Windows command prompt, navigate to c:\Octave\octave-6.4.0-w64\mingw64, and type octave.bat (no options used), it opens octave in the existing window.

Solution 2:[2]

Run Octave in VSCode Jupyter Notebook

You can change line octave-cli.exe % to octave-gui.exe --no-gui % in file octave.bat:

Rem   Start Octave (this detaches and immediately returns).

if %GUI_MODE%==1 (
  start octave-gui.exe --gui %*
) else (
  octave-gui.exe --no-gui %*
  Rem  octave-cli.exe %*
)

Instead of starting octave-cli.exe you are starting GUI octave-gui.exe --no-gui without graphical use interface.

Check available graphics toolkits in octave:

octave> available_graphics_toolkits()

Answer should be

ans = {
  [1,1] = fltk
  [1,2] = gnuplot  
  [1,3] = qt
}

Check which graphics toolkit is used

graphics_toolkit()
ans = qt

Answer should be qt. Benefit of the change is that now you can use best inline graphics in Jupyter Notebooks and also in VSCode Jupyter Notebooks.

John

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick J
Solution 2 Tyler2P