|
Configuration of ChawanChawan supports configuration of various options like keybindings, user stylesheets, site preferences, etc. The configuration format is similar to toml, with the following exceptions:
The canonical configuration file path is ~/.chawan/config.toml, but the search path accommodates XDG basedirs as well:
See the Path handling section for details on how the config directory can be accessed. For a configuration template, see bonus/config.toml in the source distribution. StartStart-up options are to be placed in the [start] section. Following is a list of start-up options: Page opened when Chawan is called with the -V option and
no other pages are passed as arguments.
Script Chawan runs on start-up. Pages will not be loaded
until this function exits. (Note however that asynchronous functions like
setTimeout do not block loading.)
When set to true or “dump”, the browser
does not take input; instead, it prints a rendered version of all buffers in
order, then exits. The difference between true and
“dump” is that true first waits for all
scripts and network requests to run to completion, while “dump”
does not. This means that true may never exit when
scripting is enabled (e.g. if a script sets
setInterval.) Piping cha to an
external program or passing the -d switch has the same
effect as setting this option to “dump”.
Whether Chawan should open a console buffer in
non-headless mode. Warning: this is only useful for debugging. Disabling this
option without manually redirecting standard error will result in error
messages randomly appearing on your screen.
BufferBuffer options are to be placed in the [buffer] section. These options are global to all buffers. For more granular filtering, use [[siteconf]]. Example:
Following is a list of buffer options:
Enable/disable author style sheets. Note that disabling
this does not affect user styles.
Enable/disable JavaScript in all buffers.
"app" also enables JavaScript APIs that can
be used to fingerprint users (e.g. querying the window’s size).
This may achieve better compatibility with websites that behave like
applications, at the cost of reduced privacy. For security and performance
reasons, users are encouraged to selectively enable JavaScript with
[[siteconf]] instead of using this setting.
Enable/disable inline image display.
Enable/disable cookies on sites. If the string
“save” is specified, then cookies are also saved to
external.cookie-file. true
still reads cookies.txt, but does not modify it. In Chawan, each website gets
a separate cookie jar, so websites relying on cross-site cookies may not work
as expected. You may use the [[siteconf]]
"share-cookie-jar" setting to adjust this
behavior for specific sites.
Enable/disable the “Referer” header.
Defaults to false. For privacy reasons, users are encouraged to leave this
option disabled, only enabling it for specific sites in
[[siteconf]].
When set to true, elements with an
“autofocus” attribute are focused on automatically after the
buffer is loaded. If scripting is enabled, this also allows scripts to focus
on elements.
Whether or not http-equiv=refresh
meta tags should be respected. “never” completely disables them,
“always” automatically accepts all of them, “ask”
brings up a pop-up menu.
Whether or not browsing history should be saved to the
disk.
Add numeric markers before links. In headless/dump mode,
this also prints a list of URLs after the page.
A user stylesheet applied to all buffers. External
stylesheets can be imported using the @import
'file.css'; syntax. Paths are relative to the configuration directory.
Nested @import is not supported yet.
SearchSearch options are to be placed in the [search] section. Following is a list of search options:
Whether on-page searches should wrap around the
document.
When set to true, document-wide searches are
case-insensitive by default. When set to “auto”, searches are
only case-sensitive when the search term includes a capital letter. Note: this
can also be overridden inline in the search bar (vim-style), with the escape
sequences \c (ignore case) and
\C (strict case). See search mode for details.
EncodingEncoding options are to be placed in the [encoding] section. Following is a list of encoding options:
List of character sets for loading documents. All listed
character sets are enumerated until the document has been decoded without
errors. In HTML, meta tags and the BOM may override this with a different
charset, so long as the specified charset can decode the document
correctly.
Character set for keyboard input and displaying
documents. Used in dump mode as well. (This means that
e.g. cha -I EUC-JP -O UTF-8 a > b is roughly
equivalent to iconv -f EUC-JP -t UTF-8.)
ExternalExternal options are to be placed in the [external] section. Following is a list of external options: Directory used to save temporary files.
External editor command. %s is substituted for the file
name, %d for the line number.
Search path for mailcap files. See cha-mailcap(5)
for details. Directories specified first have higher precedence.
Search path for mime.types files. See
cha-mime.types(5) for details.
Mailcap file for entries that are automatically executed.
The “Open as” prompt also saves entries in this file. For
backwards-compatibility, if this is “mailcap” and the file does
not exist, Chawan will also check “auto.mailcap”.
Search path for local CGI scripts. See cha-cgi(5)
for details.
Search path for urimethodmap files. See
cha-urimethodmap(5) for details.
Enable local CGI compatibility with w3m. In short, it
redirects file:///cgi-bin/* and
file:///$LIB/cgi-bin/* to
cgi-bin:*. See cha-cgi(5) for details.
Path to pre-fill for “Save to:”
prompts.
Whether about:downloads should be
opened after starting a download.
Command to use for “copy to clipboard”
operations. When input.osc52-copy is set to
“auto” (the default), copy-cmd is
ignored if support for OSC 52 is detected.
Command to use for “read from clipboard”
operations.
Path to the bookmark.md file. (The file it points to
should have a .md extension, so that its type can be correctly deduced.)
Path to the history file.
Maximum length of the history file.
Path to the cookie file. The format is equivalent to
curl’s “cookies.txt” format, except that a
“jar@” part is prepended for cookies that belong in a different
jar than the domain. Cookies from this file are used if
“buffer.cookie” (or its equivalent siteconf override) is set to
true or "save". This
means that true sets the cookie-file to a
“read-only” mode.
InputInput options are to be placed in the [input] section.
Whether vi-style numeric prefixes to commands should be
accepted. Only applies for keybindings defined in
[page].
Whether Chawan is allowed to intercept mouse clicks. The
current implementation imitates w3m. When set to “auto” (the
default), Chawan tries to detect whether mouse support is available.
Whether Chawan should use the OSC 52 escape sequence for
copying to the clipboard directly through the terminal. When available, OSC 52
overrides external.copy-cmd. When set to
“auto” (the default), Chawan tries to detect whether OSC 52 is
available on launch.
Whether Chawan should try to set the primary selection
through OSC 52. This happens automatically on mouse selection, and also on all
clipboard copies. When set to “auto” (the default), Chawan tries
to detect whether the terminal is capable of setting the primary selection.
Note that very few terminals actually implement OSC 52 correctly (to my
knowledge, only XTerm and Kitty), and on other terminals this might even break
copying to the clipboard selection.
Whether Chawan should ask for bracketed paste. When true,
the terminal will (hopefully) mark pasted text with escape sequences, which a)
ensures that pasting a newline character into the line editor does not submit
the editor, b) allows Chawan to intercept text pasted into the pager,
automatically loading it into the browser’s URL bar. When set to
“auto” (the default), Chawan tries to only enable bracketed
paste if the terminal is known not to misbehave when trying to do so.
Number of lines to scroll for a mouse wheel event.
Number of columns to scroll for a mouse side-wheel
event.
A string of characters to use in
toggleLinkHints. Any Unicode codepoint is accepted,
and they are ordered as specified in this option.
Examples:
NetworkNetwork options are to be placed in the [network] section.
Maximum number of redirections to follow.
Maximum number of simultaneous network connections
allowed in one buffer. Further connections are held back until the number
returns below the threshold.
Prepend this to URLs passed to Chawan (or typed into the
URL bar) without a scheme. Note that local files
(file: scheme) will always be checked first; only if
this fails, Chawan will retry the request with
prepend-scheme set as the scheme.
Specify a proxy for all network requests Chawan makes.
Currently, the formats http://user:pass@domain and
socks5://user:pass@domain are accepted. Unlike in
curl, socks5h is an alias of
socks5, and DNS requests are always tunneled. Can be
overridden by siteconf.
Specify a table of default headers for all HTTP(S)
network requests. Can be overridden by siteconf.
WARNING: think twice before enabling this. Allows
HTTP and HTTPS requests from the file: and
stream: schemes. This is a bad idea in general,
because it allows local files to ping remote servers (a functionality commonly
abused by HTML e-mails to track your mailbox activity). On the other hand, it
allows loading images in HTML e-mails if you don’t care about the
privacy implications.
DisplayDisplay options are to be placed in the [display] section. Following is a list of display options:
Set the color mode. “auto” for automatic
detection, “monochrome” for black on white, “ansi”
for eight ANSI plus eight aixterm colors, “eight-bit” for
256-color mode, and “true-color” for 24-bit colors.
Specifies allowed output formatting modes. Accepts the
string “auto” or an array of specific attributes.
“auto” (the default) tries to detect supported formatting modes
when launched visually, and omits all formatting modes in dump mode. An empty
array ([]) disables formatting even in visual
mode.
Disable specific formatting modes.
Specifies the image output mode. “sixel”
uses sixels for output, “kitty” uses the Kitty image display
protocol, “none” disables image display completely.
“auto” (the default) detects sixel or kitty support
automatically, and falls back to “none” when neither are
available. This is expected to work on all known terminals with functional
image support. Note that buffer.images must be enabled
for images to load at all.
Only applies when
display.image-mode="sixel". Setting this to
a number overrides the number of sixel color registers reported by the
terminal.
Enable/disable the alternative screen.
“auto” (the default) tries to detect support for this feature.
(However, since Chawan does not link to terminfo, you should not expect hacks
which remove the respective terminfo description to work.)
Set the highlight color for incremental search and marks.
CSS color names, hex values, and color functions are all accepted. In
monochrome mode, this setting is ignored; instead, reverse video is
used.
Enable/disable highlighting of marks.
Assume the terminal displays characters in the East Asian
Ambiguous category as double-width characters. Useful when
e.g. ○ occupies two cells.
Specify the minimum difference between the luminance (Y)
of the default terminal background and the foreground as represented in YUV. 0
disables this function (i.e. allows black letters on black background,
etc). Note: in the past, this option used to apply to all colors, but since
v0.3 Chawan only performs color contrast correction when either the foreground
or background color is the terminal default. Also, the contrast correction
algorithm is still not perfect, so future changes are to be expected.
Set the terminal emulator’s window title to that
of the current page.
Overrides the assumed background color of the terminal.
“auto” leaves background color detection to Chawan.
Sets the assumed foreground color of the terminal.
“auto” leaves foreground color detection to Chawan.
Fallback values for the number of columns, lines, pixels
per column, and pixels per line for the cases where it cannot be determined
automatically. (For example, these values are used in dump mode.)
Force-set columns, lines, pixels per column, or pixels
per line to the fallback values provided above.
StatusOptions concerning the status bar (last line on the screen) are to be placed in the [status] section. Following is a list of status options:
Whether or not the current line number should be
displayed.
Whether or not the link under the cursor should be
displayed.
Formatting of the status bar.
OmniruleThe omni-bar (by default opened with C-l) can be used to perform searches using omni-rules. These are to be specified as sub-keys to table [omnirule]. (The sub-key itself is ignored; you can use anything as long it doesn’t conflict with other keys.) Examples:
As noted above, the default config includes some built-in rules, selected according to the maintainer’s preference and the minimum criterion that they must work without cookies and JavaScript. Currently, these are:
Omnirule options:
Regular expression used to match the input string. Note
that websites passed as arguments are matched as well. Note: regexes are
handled according to the match mode regex handling rules.
A JavaScript function Chawan will pass the input string
to. If a new string is returned, it will be parsed instead of the old
one.
SiteconfConfiguration options can be specified for individual sites. Entries are to be specified as sub-keys to table [siteconf]. (The sub-key itself is ignored; you can use anything as long it doesn’t conflict with other keys.) Most siteconf options can also be specified globally; see the “overrides” field. Examples:
Siteconf options:
Regular expression used to match the URL. Either this or
the host option must be specified. Note: regexes are
handled according to the match mode regex handling rules.
Regular expression used to match the host part of the URL
(i.e. domain name/ip address). Either this or the
url option (but not both) must be specified. Note:
regexes are handled according to the match mode regex handling rules.
A JavaScript function Chawan will pass the site’s
URL object to. If a new URL is returned, or the URL object is modified in any
way, Chawan will transparently redirect the user to this new URL.
Whether loading (with “save”, also saving)
cookies should be allowed for this URL.
Cookie jar to use for this domain. Useful for
e.g. sharing cookies with subdomains.
Whether or not Chawan should send a Referer header when
opening requests originating from this domain. Simplified example: if you
click a link on a.com that refers to b.com, and referer-from is true, b.com is
sent “a.com” as the Referer header.
Enable/disable JavaScript execution on this site. See
buffer.scripting for details.
Enable/disable author styles (CSS) on this site.
Enable/disable loading of images on this site.
Specify the default encoding for this site.
Specify a proxy for network requests fetching contents of
this buffer.
Specify a list of default headers for HTTP(S) network
requests to this buffer.
When set to true, this disables peer and hostname
verification for SSL keys on this site, like curl
--insecure would. Please do not use this unless you are absolutely sure
you know what you are doing.
When set to true, elements with an
“autofocus” attribute are focused on automatically after the
buffer is loaded. If scripting is enabled, this also allows scripts to focus
on elements.
Whether or not http-equiv=refresh
meta tags and headers should be respected. “never” completely
disables them, “always” automatically accepts all of them,
“ask” brings up a pop-up menu.
Whether or not browsing history should be saved to the
disk for this URL.
Add numeric markers before links.
Specify a user style sheet specific to the site. Refer to
buffer.user-style for details.
KeybindingsKeybindings are to be placed in these sections:
Keybindings are configured using the syntax
Where <keybinding> is a combination of unicode characters using the syntax described below. <action> is either a command defined in the [cmd] section, or a JavaScript expression. This document only describes the pre-defined actions in the default config; for a description of the API, see cha-api(7). Examples:
Keybinding formatA keybinding is a space-separated list of keys, optionally prefixed by modifiers S- (shift), C- (control), or M- (meta). In general, ASCII/Unicode keys can be written as-is. The exception is space, which is written as SPC. Other supported named keys are: TAB, ESC, RET (return key), LF (enter key/line feed), Left, Up, Down, Right (cursor keys), PageUp, PageDown (page up/down), Home, End, and function keys F1 through F20. For backwards-compatibility, spaces can be omitted from key sequences that do not start with an upper-case letter. For example, 'gg' and 'g g' are equivalent. However, components that start with an upper-case letter (e.g. 'Gg') are reserved for key names, so those must be space-separated (e.g. 'G g') to avoid ambiguous parsing. Also, for backwards-compatibility, spaces at the beginning/end of the keybinding are translated to SPC. Pager actionsDefault keybindings are highlighted in bold.
Exit the browser.
Temporarily suspend the browser Note: this also suspends
e.g. buffer processes or CGI scripts. So if you are downloading
something, that will be delayed until you restart the process.
Open the current address in the URL bar.
Open the address of the link or image being hovered in
the URL bar. If no link/image is under the cursor, an empty URL bar is
opened.
Open the URL bar with an arbitrary search engine. At the
moment, this is Brave Search, but this may change in the future.
Duplicate the current buffer. This is a shallow clone, so
modifications to one buffer will affect the other.
Open a new buffer with the current buffer’s URL,
replacing the current buffer.
Display information about the current line on the status
line.
If viewing an HTML buffer, open a new buffer with its
source. Otherwise, open the current buffer’s contents as HTML.
Save the rendered buffer to a file.
Save the buffer’s source to a file.
Open the rendered buffer in an editor.
Open the buffer’s source in an editor.
Discard the current buffer, and move back to the
previous/next buffer depending on what the previously viewed buffer was.
Discard the current buffer, and move back to the
previous/next buffer, or open the link under the cursor.
Discard all child buffers of the current buffer.
Switch to the next or previous buffer respectively.
Directly enter a JavaScript command. Note that this
interacts with the pager, not the website being displayed.
Incremental-search for a string, highlighting the first
result, forwards or backwards.
Jump to the nth (or if unspecified, first) next/previous
search result.
Display a message of the URL or title under the cursor on
the status line. Multiple calls allow cycling through the two. (i.e. by
default, press u once -> title, press again -> URL)
Show the last alert inside the line editor. You can also
view previous ones using C-p or C-n.
Copy the current buffer’s URL to the system
clipboard.
Copy the link under the cursor to the system
clipboard.
Copy the URL of the image under the cursor to the system
clipboard.
Go to the URL currently on the clipboard.
Open the bookmark file.
Add the current page to your bookmarks.
Show hints before each link (or button). After typing a
hint, the cursor is placed on the respective link. The hint character set may
be customized with input.link-hint-chars.
Buffer actionsn refers to a number preceding the action. e.g. in 10gg, n is 10. If no preceding number is input, then it is left unspecified. Default keybindings are highlighted in bold.
Move the cursor upwards/downwards by
n lines, or if n is
unspecified, by 1.
Move the cursor to the left/right by
n cells, or if n is
unspecified, by 1.
Move the cursor to the first cell of the line.
Move the cursor to the first non-blank character of the
line.
Move the cursor to the last cell of the line.
Move the cursor to the beginning of the nth next
word.
Move the cursor to the end of the current word, or if
already there, to the end of the nth next word.
Move the cursor to the beginning of the current word, or
if already there, to the end of the nth previous word.
Move the cursor to the end/beginning of the previous/next
clickable element (e.g. link, input field, etc).
Move the cursor to the end/beginning of the nth
previous/next paragraph.
Scroll up/down/left/right by n
pages, or if n is unspecified, by one page.
Scroll up/down/left/right by n
half pages, or if n is unspecified, by one page.
Scroll up/down/left/right by n
lines, or if n is unspecified, by one line.
Click the HTML element currently under the cursor.
n specifies the number of clicks in JS events.
Send a right click to the buffer. If it doesn’t
catch the event (i.e. no JS context menu is shown), toggle the menu
instead.
Toggle the menu.
View the image currently under the cursor in an external
viewer.
Reshape the current buffer (=render the current page
anew). Useful if the layout is not updating even though it should have.
Redraw screen contents. Useful if something messed up the
display.
Move to the first line/line in the middle of/last line on
the screen. (Equivalent to H,
M, L in vi.)
If n is specified, move cursor to
line n. Then,
If n is specified, move to the
screen before the nth line and raise the page. Otherwise, go to the next
screen’s first line and raise the page.
If n is specified, move to the
screen before the nth line and lower the page. Otherwise, go to the previous
screen’s last line and lower the page.
Move to the first/middle/last column on the screen.
If n is specified, jump to line
n. Otherwise, jump to the first/last line of the
buffer.
If n is specified, jump to column
n of the current line. Otherwise, jump to the
first/last column.
Wait for a character x and then
set a mark with the ID x.
Wait for a character x and then
jump to the mark with the ID x (if it exists on the
page). gotoMark sets both the X and Y positions;
gotoMarkY only sets the Y position.
Convert URL-like strings to anchors on the current
page.
Save resource from the URL pointed to by the cursor to
the disk.
Save the source of the current buffer to the disk.
Save the image currently under the cursor.
Toggle display of images in the current buffer.
Reload the current buffer with scripting
enabled/disabled.
Reload the current buffer with cookies
enabled/disabled.
Search for the word currently under the cursor.
Search for the word currently under the cursor,
backwards.
Line-editing actions
Submit the currently entered text.
Close the editor and cancel the operation it was opened
for.
If there is an active selection, copy it. Otherwise,
it’s the same as line.cancel.
Delete character before (backspace)/after (delete) the
cursor.
Delete text before (clear)/after (kill) the cursor.
Open the line editor’s contents in $EDITOR.
Delete word before (clear)/after (kill) the cursor.
Move cursor backward/forward by one character.
Move cursor to the previous/next word by one
character
Move cursor to the beginning/end of the line.
Ignore keybindings for next character.
Jump to the previous/next history entry
Note: to facilitate URL editing, the line editor has a different definition of what a word is than the pager. For the line editor, a word is either a sequence of alphanumeric characters, or any single non-alphanumeric character. (This means that e.g. https:// consists of four words: https, :, / and /.)
Regex handlingRegular expressions are currently handled using the libregexp library from QuickJS. This means that all regular expressions work as in JavaScript. There are two different modes of regex preprocessing in Chawan: “search” mode and “match” mode. Match mode is used for configurations (meaning in all values in this document described as “regex”). Search mode is used for the on-page search function (using searchForward/isearchForward etc.) Match modeRegular expressions are assumed to be exact matches, except when they start with a caret (^) sign or end with an unescaped dollar ($) sign. In other words, the following transformations occur:
Match mode has no way to toggle JavaScript regex flags like i. Search modeFor on-page search, the above transformations do not apply; the search /abcd searches for the string abcd inside all lines. Search mode also has some other convenience transformations (these do not work in match mode):
Like match mode, search mode operates on individual lines. This means that search patterns do not match text wrapped over multiple lines. Path handlingRules for path handling are similar to how the shell handles strings.
Some environment variables are also exported by Chawan:
Word typesWord-based pager commands can operate with different definitions of words. Currently, these are:
w3m wordA w3m word is a sequence of alphanumeric characters. Symbols are treated in the same way as whitespace. vi wordA vi word is a sequence of characters in the same character category. Currently, character categories are alphanumeric characters, symbols, han letters, hiragana, katakana, and hangul. vi words may be separated by whitespace; however, vi words from separate categories do not have to be whitespace-separated. e.g. the following character sequence contains two words:
Big wordA big word is a sequence of non-whitespace characters. It is essentially the same as a w3m word, but with symbols being defined as non-whitespace. See alsocha(1) cha-api(7)
|