This chapter tells how to run Leo and discusses Leo’s command-line options.
You can run Leo from a Python interpreter as follows:
import leo leo.run() # runs Leo, opening a new outline or, leo.run(fileName=aFileName) # runs Leo, opening the given file name.
Another way to run Leo is as follows:
cd <path-to-launchLeo.py> python launchLeo.py %*
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:
#!/bin/sh python <leopath>launchLeo.py $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>/launchLeo.py %*
Here <path-to-leo> is the path to the directory containing the leo directory, that is, the directory containing launchLeo.py.
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.
On startup, Leo looks for two arguments of the form:
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" g.app.log.disable() # disable reading messages while opening the file flag,newFrame = g.openWithFileName(path,None) g.app.log.enable() # re-enable the log. for p in newFrame.c.all_positions(): g.es(g.toEncodedString(p.h,"utf-8"))
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.
Leo supports the following command-line options. As usual, you can see the list by typing the following in a console window:
You will get something like the following:
Usage: launchLeo.py [options] file1, file2, ... Options: -h, --help show this help message and exit --debug enable debug mode --diff use Leo as an external git diff --fullscreen start fullscreen --ipython enable ipython support --gui=GUI gui to use (qt/qttabs) --maximized start maximized --minimized start minimized --no-cache disable reading of cached files --no-plugins disable all plugins --no-splash disable the splash screen --screen-shot=SCREENSHOT_FN take a screen shot and then exit --script=SCRIPT execute a script and then exit --script-window=SCRIPT_WINDOW open a window for scripts --select=SELECT headline or gnx of node to select --session-restore restore previously saved session tabs at startup --session-save save session tabs on exit --silent disable all log messages --trace-plugins trace imports of plugins -v, --version print version number and exit --window-size=WINDOW_SIZE initial window size (height x width)
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.
A session specifies a list of tabs (.leo files) that Leo opens automatically when Leo first starts.
The typical usage is to start Leo with the
--session-save --session-restore command-line options, open several Leo files and exit.
The next time Leo is started with those options, the files will be open, and the nodes focused as when the previous session ended.
Leo stores session state in