Repository: borgbackup/borg

Issue:
environment variables for borg list formats
## Have you checked borgbackup docs, FAQ, and open Github issues?

Yes

## Is this a BUG / ISSUE report or a QUESTION?

Issue (Enhancement Request)

#### Your borg version (borg -V).

`borg 1.1.11`

#### Full borg commandline that lead to the problem (leave away excludes and passwords)

`borg list --format '{archive:40} {time} [{id}]{NL}'`

## Describe the problem you're observing.

My archive names are a bit long, so in order to make `bog list` output prettier I use the `--format` option to expand the `archive` column to 40 characters, instead the default 36 . There are two issues with this:

1. It's annoying to have to type this in every time.
2. I only want this format for archive lists, not file lists, so I can't really alias `borg list`.

It would be really nice to have these two environment variables:

- `BORG_LIST_ARCHIVE_FORMAT`
- `BORG_LIST_FILE_FORMAT`



Discussion:
For borg2, that would be:
```
BORG_RLIST_FORMAT  # "repo list -> archives"
BORG_LIST_FORMAT  # "archive list -> files"
BORG_XXXX_FORMAT
```

Resolving patch:
diff --git a/src/borg/archiver/list_cmd.py b/src/borg/archiver/list_cmd.py
--- a/src/borg/archiver/list_cmd.py
+++ b/src/borg/archiver/list_cmd.py
@@ -1,4 +1,5 @@
 import argparse
+import os
 import textwrap
 import sys
 
@@ -24,7 +25,7 @@ def do_list(self, args, repository, manifest):
         elif args.short:
             format = "{path}{NL}"
         else:
-            format = "{mode} {user:6} {group:6} {size:8} {mtime} {path}{extra}{NL}"
+            format = os.environ.get("BORG_LIST_FORMAT", "{mode} {user:6} {group:6} {size:8} {mtime} {path}{extra}{NL}")
 
         def _list_inner(cache):
             archive = Archive(manifest, args.name, cache=cache)
diff --git a/src/borg/archiver/prune_cmd.py b/src/borg/archiver/prune_cmd.py
--- a/src/borg/archiver/prune_cmd.py
+++ b/src/borg/archiver/prune_cmd.py
@@ -3,6 +3,7 @@
 from datetime import datetime, timezone, timedelta
 import logging
 from operator import attrgetter
+import os
 import re
 
 from ._common import with_repository, Highlander
@@ -87,7 +88,7 @@ def do_prune(self, args, repository, manifest):
         elif args.short:
             format = "{archive}"
         else:
-            format = "{archive:<36} {time} [{id}]"
+            format = os.environ.get("BORG_PRUNE_FORMAT", "{archive:<36} {time} [{id}]")
         formatter = ArchiveFormatter(format, repository, manifest, manifest.key, json=False, iec=args.iec)
 
         checkpoint_re = r"\.checkpoint(\.\d+)?"
diff --git a/src/borg/archiver/rlist_cmd.py b/src/borg/archiver/rlist_cmd.py
--- a/src/borg/archiver/rlist_cmd.py
+++ b/src/borg/archiver/rlist_cmd.py
@@ -1,4 +1,5 @@
 import argparse
+import os
 import textwrap
 import sys
 
@@ -21,7 +22,7 @@ def do_rlist(self, args, repository, manifest):
         elif args.short:
             format = "{archive}{NL}"
         else:
-            format = "{archive:<36} {time} [{id}]{NL}"
+            format = os.environ.get("BORG_RLIST_FORMAT", "{archive:<36} {time} [{id}]{NL}")
         formatter = ArchiveFormatter(format, repository, manifest, manifest.key, json=args.json, iec=args.iec)
 
         output_data = []


Test patch: