aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-10-13 00:03:42 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-16 11:35:24 +0200
commitebfd2a9da3d63390a9d4a0c227b2513a0dac19a4 (patch)
treeedae511a998f7d3a0427649342294ecaf09f5454 /widgets
parent9bd2e0c84fef66007bcab027883c01414b99b77c (diff)
downloadaerc-ebfd2a9da3d63390a9d4a0c227b2513a0dac19a4.tar.gz
filters: export mime type and filename in env
Export AERC_MIME_TYPE and AERC_FILENAME in the filters command environment. This allows dynamic coloring with tools that require a filename and/or a mime type to determine the syntax. Update docs and add example use in the default config file. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/msgviewer.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 70c079a3..a32e0399 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -541,8 +541,9 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig,
pager = exec.Command(cmd[0], cmd[1:]...)
info := msg.MessageInfo()
+ mime := part.FullMIMEType()
+
for _, f := range conf.Filters {
- mime := part.FullMIMEType()
switch f.FilterType {
case config.FILTER_MIMETYPE:
if fnmatch.Match(f.Filter, mime, 0) {
@@ -577,6 +578,10 @@ func NewPartViewer(acct *AccountView, conf *config.AercConfig,
}
filter.Env = os.Environ()
filter.Env = append(filter.Env, fmt.Sprintf("PATH=%s", path))
+ filter.Env = append(filter.Env,
+ fmt.Sprintf("AERC_MIME_TYPE=%s", mime))
+ filter.Env = append(filter.Env,
+ fmt.Sprintf("AERC_FILENAME=%s", part.FileName()))
if pipe, err = filter.StdinPipe(); err != nil {
return nil, err
}