lnav/docs/source/config.rst

214 lines
7.4 KiB
ReStructuredText
Raw Normal View History

2013-07-27 18:04:43 +00:00
2020-05-07 14:08:59 +00:00
.. _Configuration:
2013-07-27 18:04:43 +00:00
Configuration
=============
2020-05-07 14:08:59 +00:00
The configuration for **lnav** is stored in the following JSON files in
:file:`~/.lnav`:
2020-09-03 21:09:21 +00:00
* :file:`config.json` -- Contains local customizations that were done using the
2020-05-07 14:08:59 +00:00
:code:`:config` command.
2020-09-03 21:09:21 +00:00
* :file:`configs/default/*.json` -- The default configuration files that are
2020-05-07 14:08:59 +00:00
built into lnav are written to this directory with :file:`.sample` appended.
Removing the :file:`.sample` extension and editing the file will allow you to
do basic customizations.
2020-09-03 21:09:21 +00:00
* :file:`configs/installed/*.json` -- Contains configuration files installed
using the :option:`-i` flag (e.g. :code:`$ lnav -i /path/to/config.json`).
2020-09-03 21:09:21 +00:00
* :file:`configs/*/*.json` -- Other directories that contain :file:`*.json`
2020-09-14 06:03:23 +00:00
files will be loaded on startup. This structure is convenient for installing
**lnav** configurations, like from a git repository.
A valid **lnav** configuration file must contain an object with the
:code:`$schema` property, like so:
.. code-block:: json
{
"$schema": "https://lnav.org/schemas/config-v1.schema.json"
}
2020-05-07 14:08:59 +00:00
.. note::
Log format definitions are stored separately in the :file:`~/.lnav/formats`
directly. See the :ref:`Log Formats<log_formats>` chapter for more
information.
2020-09-10 05:14:17 +00:00
2020-05-07 14:08:59 +00:00
Options
-------
2020-09-10 05:14:17 +00:00
The following configuration options can be used to customize **lnav** to
your liking. The options can be changed using the :code:`:config` command.
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/keymap
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/theme
2020-05-07 14:08:59 +00:00
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/clock-format
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/dim-text
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/default-colors
2020-09-10 05:14:17 +00:00
.. _themes:
2020-05-07 14:08:59 +00:00
Theme Definitions
-----------------
2020-05-07 14:08:59 +00:00
2020-09-14 06:03:23 +00:00
User Interface themes are defined in a JSON configuration file. A theme is
made up of the style definitions for different types of text in the UI. A
:ref:`definition<theme_style>` can include the foreground/background colors
and the bold/underline attributes. The style definitions are broken up into
multiple categories for the sake of organization. To make it easier to write
a definition, a theme can define variables that can be referenced as color
values.
Variables
^^^^^^^^^
The :code:`vars` object in a theme definition contains the mapping of variable
names to color values. These variables can be referenced in style definitions
by prefixing them with a dollar-sign (e.g. :code:`$black`). The following
variables can also be defined to control the values of the ANSI colors that
are log messages or plain text:
2021-03-30 21:12:09 +00:00
.. csv-table:: ANSI colors
:header: "Variable Name", "ANSI Escape"
"black", "ESC[30m"
"red", "ESC[31m"
"green", "ESC[32m"
"yellow", "ESC[33m"
"blue", "ESC[34m"
"magenta", "ESC[35m"
"cyan", "ESC[36m"
"white", "ESC[37m"
2020-09-14 06:03:23 +00:00
Specifying Colors
^^^^^^^^^^^^^^^^^
Colors can be specified using hexadecimal notation by starting with a hash
(e.g. :code:`#aabbcc`) or using a color name as found at
http://jonasjacek.github.io/colors/. If colors are not specified for a style,
the values from the :code:`styles/text` definition.
.. note::
When specifying colors in hexadecimal notation, you do not need to have an
exact match in the XTerm 256 color palette. A best approximation will be
picked based on the `CIEDE2000 <https://en.wikipedia.org/wiki/Color_difference#CIEDE2000>`_
color difference algorithm.
Example
^^^^^^^
The following example sets the black/background color for text to a dark grey
using a variable and sets the foreground to an off-white. This theme is
incomplete, but it works enough to give you an idea of how a theme is defined.
You can copy the code block, save it to a file in
:file:`~/.lnav/configs/installed/` and then activate it by executing
:code:`:config /ui/theme example` in lnav. For a more complete theme
definition, see one of the definitions built into **lnav**, like
`monocai <https://github.com/tstack/lnav/blob/master/src/themes/monocai.json>`_.
.. code-block:: json
{
"$schema": "https://lnav.org/schemas/config-v1.schema.json",
"ui": {
"theme-defs": {
"example1": {
"vars": {
"black": "#2d2a2e"
},
"styles": {
"text": {
"color": "#f6f6f6",
"background-color": "$black"
}
}
}
}
}
}
Reference
^^^^^^^^^
2020-05-07 14:08:59 +00:00
2020-05-15 18:02:46 +00:00
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/theme-defs/patternProperties/([\w\-]+)/properties/vars
2020-05-07 14:08:59 +00:00
2020-05-15 18:02:46 +00:00
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/theme-defs/patternProperties/([\w\-]+)/properties/styles
2020-05-07 14:08:59 +00:00
2020-09-14 06:03:23 +00:00
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/theme-defs/patternProperties/([\w\-]+)/properties/syntax-styles
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/theme-defs/patternProperties/([\w\-]+)/properties/status-styles
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/theme-defs/patternProperties/([\w\-]+)/properties/log-level-styles
.. _theme_style:
2020-05-07 14:08:59 +00:00
.. jsonschema:: ../../src/internals/config-v1.schema.json#/definitions/style
2020-09-10 05:14:17 +00:00
2020-05-13 16:38:41 +00:00
.. _keymaps:
Keymap Definitions
------------------
2020-05-07 14:08:59 +00:00
2020-09-14 06:03:23 +00:00
Keymaps in **lnav** map a key sequence to a command to execute. When a key is
pressed, it is converted into a hex-encoded string that is looked up in the
keymap. The :code:`command` value associated with the entry in the keymap is
then executed. Note that the "command" can be an **lnav**
:ref:`command<commands>`, a :ref:`SQL statement/query<sql-ext>`, or an
**lnav** script. If an :code:`alt-msg` value is included in the entry, the
bottom-right section of the UI will be updated with the help text.
.. note::
Not all functionality is available via commands or SQL at the moment. Also,
some hotkeys are not implemented via keymaps.
Key Sequence Encoding
^^^^^^^^^^^^^^^^^^^^^
Key presses are converted into a hex-encoded string that is used to lookup an
entry in the keymap. Each byte of the keypress value is formatted as an
:code:`x` followed by the hex-encoding in lowercase. For example, the encoding
2020-09-15 22:45:29 +00:00
for the £ key would be :code:`xc2xa3`. To make it easier to discover the
encoding for unassigned keys, **lnav** will print in the command prompt the
:code:`:config` command and
`JSON-Pointer <https://tools.ietf.org/html/rfc6901>`_ for assigning a command
to the key.
.. figure:: key-encoding-prompt.png
:align: center
Screenshot of the command prompt when an unassigned key is pressed.
2020-09-14 06:03:23 +00:00
.. note::
Since **lnav** is a terminal application, it can only receive keypresses that
can be represented as characters or escape sequences. For example, it cannot
2020-09-15 22:45:29 +00:00
handle the press of a modifier key.
2020-09-14 06:03:23 +00:00
Reference
^^^^^^^^^
2020-05-07 14:08:59 +00:00
2020-05-15 18:02:46 +00:00
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/ui/properties/keymap-defs/patternProperties/([\w\-]+)
2021-01-24 22:35:14 +00:00
.. _tuning:
2021-01-24 22:35:14 +00:00
Tuning
------
The following configuration options can be used to tune the internals of
**lnav** to your liking. The options can be changed using the :code:`:config`
command.
.. jsonschema:: ../../src/internals/config-v1.schema.json#/properties/tuning