Running Leo

This chapter tells how to run Leo and discusses Leo’s command-line options.

Running Leo

You can run Leo from a Python interpreter as follows:

import leo # runs Leo, opening a new outline or, # runs Leo, opening the given file name.

Another way to run Leo is as follows:

cd <>
python %*

Here are some tips that may make running Leo easier:


The following shell script will allow you to open foo.leo files by typing leo foo:

python <leopath> $1

where <leopath> is the path to the directory containing the leo directory.


You can associate Leo with .leo files using a batch file. Put the following .bat file in c:\Windows:

<path-to-python>/python <path-to-leo>/ %*

Here <path-to-leo> is the path to the directory containing the leo directory, that is, the directory containing

Running Leo the first time

The first time you start Leo, a dialog will ask you for a unique identifier. If you are using a source code control system such as git, use your git login name. Otherwise your initials will do.

Leo stores this identifier in the file .leoID.txt. Leo attempts to create leoID.txt in the .leo sub-directory of your home directory, then in Leo’s config directory, and finally in Leo’s core directory. You can change this identifier at any time by editing .leoID.txt.

Running Leo in batch mode

On startup, Leo looks for two arguments of the form:

--script scriptFile

If found, Leo enters batch mode. In batch mode Leo does not show any windows. Leo assumes the scriptFile contains a Python script and executes the contents of that file using Leo’s Execute Script command. By default, Leo sends all output to the console window. Scripts in the scriptFile may disable or enable this output by calling app.log.disable or app.log.enable

Scripts in the scriptFile may execute any of Leo’s commands except the Edit Body and Edit Headline commands. Those commands require interaction with the user. For example, the following batch script reads a Leo file and prints all the headlines in that file:

path = r"<path-to-folder-containing-the-leo-folder>\\leo\\test\\test.leo" # disable reading messages while opening the file
flag,newFrame = g.openWithFileName(path,None) # re-enable the log.

for p in newFrame.c.all_positions():,"utf-8"))

Running Leo from a console window

Leo sends more detailed error messages to stderr, the output stream that goes to the console window. In Linux and MacOS environments, python programs normally execute with the console window visible.

On Windows, you can run Leo with the console window visible by associating .leo files with python.exe not pythonw.exe.

Running Leo after pip install leo

After running pip install leo from a console type:

``leo`` - start Leo in normal graphical mode (qt)
``leo-c``, ``leo-console`` - start Leo in console (curses) mode
``leo-m``, ``leo-messages`` - start Leo in normal (qt) mode, and echo log messages to the starting shell

The launchers are installed in PYTHONHOME/Scripts.

The .leo directory

Leo uses os.expanduser(‘~’) to determine the HOME directory if no HOME environment variable exists.

Leo puts several files in your HOME/.leo directory: .leoID.txt, .leoRecentFiles.txt, and myLeoSettings.leo.

Leo’s command-line options

Leo supports the following command-line options. As usual, you can see the list by typing the following in a console window:

leo -h


leo --help

You will get something like the following:

Usage: [options] file1, file2, ...

  -h, --help            show this help message and exit
  --diff                use Leo as an external git diff
  --fullscreen          start fullscreen
  --ipython             enable ipython support
  --fail-fast           stop unit tests after the first failure
  --gui=GUI             gui to use (qt/qttabs/console/null)
  --listen-to-log       start on startup
  --load-type=TYPE      @<file> type for non-outlines
  --maximized           start maximized
  --minimized           start minimized
  --no-plugins          disable all plugins
  --no-splash           disable the splash screen
  --screen-shot=PATH    take a screen shot and then exit
  --script=PATH         execute a script and then exit
  --script-window       execute script using default gui
  --select=ID           headline or gnx of node to select
  --silent              disable all log messages
  --theme=NAME          use the named theme file
                        add one or more strings to
  --trace-binding=KEY   trace commands bound to a key
  --trace-setting=NAME  trace where named setting is set
  --window-size=SIZE    initial window size (height x width)
  -v, --version         print version number and exit


Use one of the following command-line arguments to start Leo in a web browser:

leo --gui=browser
leo --gui=browser-firefox-browser​

For details, see

Leo’s workbook file

If you give no file arguments on the command line Leo will open ~/.leo/workbook.leo. Initially, this file contains Leo’s cheat sheet and an example from the rst3 tutorial.

Using sessions

A session specifies a list of .leo files that Leo opens automatically when Leo first starts. Leo will reload the last session provided that command-line arguments don’t contain any file names.

Leo stores session state in ~/.leo/leo.session. Session state consists of the list of open files and the selected node in each file.