From b1f16c84e0be8d3074139f0be56e0852acceaef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 4 Feb 2025 10:10:10 +0100 Subject: [PATCH] doc: improve regex example --- doc/foot.ini.5.scd | 19 ++++++++++--------- foot.ini | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 89984ef5..68216fcd 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -801,16 +801,17 @@ Similar to the 'url' mode, but with custom defined regular expressions To use a custom defined regular expression, you also need to add a key binding for it. This is done in the *key-binding* section, see below -for details. In short, you need to: +for details. For example, a regex to detect hash digests (e.g. git +commit hashes) could look like: ``` -[regex:foo] -regex=foo(bar)? +[regex:hashes] +regex=([a-fA-f0-9]{7,128}) launch=path-to-script-or-application ${match} [key-bindings] -regex-launch=[foo] Control+Shift+q -regex-copy=[foo] Control+Mod1+Shift+q +regex-launch=[hashes] Control+Shift+q +regex-copy=[hashes] Control+Mod1+Shift+q ``` *launch* @@ -1278,13 +1279,13 @@ e.g. *search-start=none*. binding: ``` - [regex:foo] - regex=foo(bar)? + [regex:hashes] + regex=([a-fA-f0-9]{7,128}) launch=path-to-script-or-application ${match} [key-bindings] - regex-launch=[foo] Control+Shift+q - regex-copy=[foo] Control+Mod1+Shift+q + regex-launch=[hashes] Control+Shift+q + regex-copy=[hashes] Control+Mod1+Shift+q ``` Default: _none_. diff --git a/foot.ini b/foot.ini index 2489887f..a1aa118c 100644 --- a/foot.ini +++ b/foot.ini @@ -73,7 +73,7 @@ # You can define your own regex's, by adding a section called # 'regex:' with a 'regex' and 'launch' key. These can then be tied -# to a key-binding: +# to a key-binding. See foot.ini(5) for details # [regex:your-fancy-name] # regex=