diff --git a/scripts/shell_completions/zsh/_borg b/scripts/shell_completions/zsh/_borg index 41aaa7e0..aa9b59ce 100644 --- a/scripts/shell_completions/zsh/_borg +++ b/scripts/shell_completions/zsh/_borg @@ -1129,7 +1129,7 @@ _borg_format_keys() { local repo_or_arch=${(Q)1} local -a keys=( NEWLINE NL NUL SPACE TAB CR LF ) - local -a repository_keys=( archive name barchive comment bcomment id start time end hostname username ) + local -a repository_keys=( archive name barchive comment bcomment id start time end command_line hostname username ) local -a archive_keys=( type mode uid gid user group path bpath source linktarget flags size csize dsize dcsize num_chunks unique_chunks mtime ctime atime isomtime isoctime isoatime blake2b blake2s md5 sha1 sha224 sha256 sha384 sha3_224 sha3_256 sha3_384 sha3_512 sha512 shake_128 shake_256 archiveid archivename extra health ) diff --git a/src/borg/helpers.py b/src/borg/helpers.py index c9568010..75fa53c7 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -1795,13 +1795,14 @@ class ArchiveFormatter(BaseFormatter): 'start': 'time (start) of creation of the archive', 'time': 'alias of "start"', 'end': 'time (end) of creation of the archive', + 'command_line': 'command line which was used to create the archive', 'id': 'internal ID of the archive', 'hostname': 'hostname of host on which this archive was created', 'username': 'username of user who created this archive', } KEY_GROUPS = ( ('archive', 'name', 'barchive', 'comment', 'bcomment', 'id'), - ('start', 'time', 'end'), + ('start', 'time', 'end', 'command_line'), ('hostname', 'username'), ) @@ -1850,6 +1851,7 @@ class ArchiveFormatter(BaseFormatter): 'comment': partial(self.get_meta, 'comment', rs=True), 'bcomment': partial(self.get_meta, 'comment', rs=False), 'end': self.get_ts_end, + 'command_line': self.get_cmdline, } self.used_call_keys = set(self.call_keys) & self.format_keys if self.json: @@ -1890,6 +1892,13 @@ class ArchiveFormatter(BaseFormatter): value = self.archive.metadata.get(key, '') return remove_surrogates(value) if rs else value + def get_cmdline(self): + cmdline = map(remove_surrogates, self.archive.metadata.get('cmdline', [])) + if self.json: + return list(cmdline) + else: + return ' '.join(map(shlex.quote, cmdline)) + def get_ts_end(self): return self.format_time(self.archive.ts_end)