kimono-koans / httm

Interactive, file-level Time Machine-like tool for ZFS/btrfs/nilfs2 (and even Time Machine and Restic backups!)
https://crates.io/crates/httm
Mozilla Public License 2.0
1.33k stars 28 forks source link

feature request: live-preview of file content for text files in interactive mode #55

Closed arctic-penguin closed 1 year ago

arctic-penguin commented 1 year ago

Like this: https://nickjanetakis.com/blog/using-fzf-to-preview-text-files-on-the-command-line-and-within-vim

Use case: the user has written any text file over some time. He has overwritten some past changes. He would like to check if the specific changes are contained in any of the snapshots of the file.

So something like:

  1. $ httm -r my_file.txt
  2. the snapshot selection and the preview window show up
  3. the preview pane shows the file in snapshotted state, and allows for some scrolling and such

Preview could use bat if it is installed to provide syntax highlighting, otherwise less

This could be extended to generate diffs between versions from different snapshots, but that is another story.

kimono-koans commented 1 year ago

Use case: the user has written any text file over some time. He has overwritten some past changes. He would like to check if the specific changes are contained in any of the snapshots of the file.

Check out bowie which already does something similar as a script.

But this is definitely possible! It may require another exec mode but its definitely doable. And I think the questions are only: Is it worth adding if one has bowie already? Do you make it automatic for text? If so how does one easily detect text or binary files? Are there good crates which can diff the output or do we just use diff, perhaps make the preview selectable via an env var and at the command line, like SELECT_PREVIEW_CMD="diff --color (snap} {live} | bat", etc.

Please let me know your thoughts!

Thanks! Appreciate you taking a look at the project.

kimono-koans commented 1 year ago

Completed with: https://github.com/kimono-koans/httm/pull/56