This package is based on antham's helm-backup, and uses his git-backup library.
consult-local-history provides a similar interface to helm-backup to manage
a local file history using a git
repository, but using
consult and
embark as the front end.
consult-local-history can be downloaded here.
The package requires git
, git-backup
, consult
and embark
.
-
Every time a file is saved, it is automatically committed to the local history repository.
-
To add a more descriptive commit message for certain states, save manually using
consult-local-history-named-save-file
-
Use
consult-local-history
to view the available backups for the current buffer file. It will show the date, commit message and a preview of the changes introduced with each backup. -
Use embark actions from within
consult-local-history
. There are three supported actions:<RET>
: default, opens the selected backup in a new buffer."e"
: ediff between the selected backup and the current buffer."r"
: revert current buffer to the state of the selected backup.
-
Use
consult-local-history-delete-file
to remove a file from the local history repository.
Using straight.el
:
;; required
(use-package git-backup
:straight t
)
(use-package consult-local-history
:straight (consult-local-history
:host github
:repo "dawsers/consult-local-history"
)
)
There are several variables that can be customized. Their default value between
()
:
-
consult-local-history-path
("~/.emacs-backups/consult-local-history"
): Storage path for local history repository. -
consult-local-history-git-binary
("git"
):git
binary to use. -
consult-local-history-list-format
("%cd, %ar"
): Format for the backup time displayed. -
consult-local-history-excluded-entries
(nil
): List of file/folder regexp to exclude from local history.
You can also customize the faces used by consult-local-history
to display the
backup's date and commit comment:
-
consult-local-history-date
(font-lock-constant-face
) -
consult-local-history-comment
(font-lock-comment-face
)
-
consult-local-history
: View and manage the available backups in the local history repository for the current buffer file. As described above, there are three possible actions for the selected candidate, using embark.<RET>
: default, opens the selected backup in a new buffer."e"
: ediff between the selected backup and the current buffer."r"
: revert current buffer to the state of the selected backup.
The preview buffer shows the changes introduced with the currently selected backup.
-
consult-local-history-delete-file
: Removes a file from the local history repository. -
consult-local-history-named-save-file
: Saves the current buffer and adds a custom commit message for the local history backup. Use it for important saves.
None for the interactive commands, so you can select your own. The embark actions have a map with the bindings described above.