aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/aerc-templates.7.scd9
-rw-r--r--lib/templates/functions.go5
2 files changed, 14 insertions, 0 deletions
diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd
index 8e1bcf1b..91745e8c 100644
--- a/doc/aerc-templates.7.scd
+++ b/doc/aerc-templates.7.scd
@@ -352,6 +352,15 @@ aerc provides the following additional functions:
{{cwd}}
```
+*compactDir*
+ Reduce a directory path into a compact form. The directory name will be
+ split with _/_ and each part will be reduced to the first letter in its
+ name: _INBOX/01_WORK/PROJECT_ will become _I/W/PROJECT_.
+
+ ```
+ {{compactPath .Folder}}
+ ```
+
*version*
Returns the version of aerc, which can be useful for things like X-Mailer.
diff --git a/lib/templates/functions.go b/lib/templates/functions.go
index 0b0a4546..1cbdc85d 100644
--- a/lib/templates/functions.go
+++ b/lib/templates/functions.go
@@ -246,6 +246,10 @@ func trimSignature(message string) string {
return res.String()
}
+func compactDir(path string) string {
+ return format.CompactPath(path, os.PathSeparator)
+}
+
var templateFuncs = template.FuncMap{
"quote": quote,
"wrapText": wrapText,
@@ -266,4 +270,5 @@ var templateFuncs = template.FuncMap{
"cwd": cwd,
"join": join,
"trimSignature": trimSignature,
+ "compactDir": compactDir,
}