summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorDavid Peter <sharkdp@users.noreply.github.com>2020-10-11 21:07:56 +0200
committerGitHub <noreply@github.com>2020-10-11 21:07:56 +0200
commit0a28da0cd018f2602677dcb04f8abef9aaabf523 (patch)
treec466e7874796ca2d1d8c30c3acb744c64b411222 /README.md
parenta838ff47b5f5ec6153f3ff63087ee7ef3df24dd2 (diff)
Small improvement to the syntax mapping section
Diffstat (limited to 'README.md')
-rw-r--r--README.md27
1 files changed, 16 insertions, 11 deletions
diff --git a/README.md b/README.md
index 24239ded..d42ea473 100644
--- a/README.md
+++ b/README.md
@@ -490,27 +490,32 @@ and the `GitHub` theme when in the _light mode_.
alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"
```
-### Syntax of a file
+### Adapting file type associations
-You can change the default syntax association of the file using the `--map-syntax` option.
-It supports glob pattern matching and is matched on full path and filename.
+You can add new (or change existing) file name patterns using the
+`--map-syntax` option. The option takes an argument of the form `pattern:syntax`.
+`pattern` is a glob pattern that is matched against the file name and
+the absolute file path. `syntax` is the *name* of a supported language
+(use `bat --list-languages` for an overview).
-You can use it like this:
+This option is most useful in combination with the `bat` configuration file (see below).
+Example: To use "INI" syntax highlighting for all files with a `.conf` file extension, use
```bash
-bat --map-syntax='PATTERN:SYNTAX' file-name
+--map-syntax='*.conf:INI'
```
-For example:
+Example: To open all files called `.ignore` (exact match) with the "Git Ignore" syntax, use:
```bash
-# Using `INI` file syntax highlighting when opening a file with extension `.conf`.
-bat --map-syntax='*.conf:INI' file.conf
+--map-syntax='.ignore:Git Ignore'
+```
-# Using `Git Ignore` file syntax highlighting for ".ignore" files
-bat --map-syntax='.ignore:Git Ignore' .ignore
+Example: To open all `.conf` files in subfolders of `/etc/apache2` with the "Apache Conf"
+syntax, use (this mapping is already built in):
+```bash
+-map-syntax='/etc/apache2/**/*.conf:Apache Conf'
```
-You can use `bat --list-languages` to see all the file syntax types available.
## Configuration file