So playing with Restic and NCDU got me thinking… it would be cool if Restic could pipe something akin to --ncdu (or exactly ncdu’s format) to a helper application that would let you browse just like NCDU, but upon hitting “return” it would exit and spit out the restore command.
Say you browse to /Volumes/Users/akrabu/Desktop/my-stuff in the helper app, then hit “return” (or some key combo) - it would then take you back to the terminal with “restic restore :/Volumes/Users/akrabu/Desktop/my-stuff -t .” filled in and ready for you.
Wonder if NCDU could be forked for this? Unfortunately I’m nowhere near talented enough to pull this off myself, but… it sure would be handy!
The functionality I’m thinking of is similar to what fzf does, if anyone uses that to search their files in the terminal. Whatever line is highlighted gets spit out to the terminal when you hit return.
EDIT: Might make more sense for me to make a request on NCDU’s site for a switch that outputs selected paths / the last path upon exit?
(just my opinon) unless size is somehow more important than the ability to fuzzy search on the name, using ncdu is not worth it – I normally just pipe the list into fzf and feed the output to restic restore, as you said.
However, I was intrigued by the idea of somehow using ncdu. Here’s what I came up with but this is a horrible kludge:
use gdu instead of ncdu; it takes the same output file as ncdu (i.e., restic ls --ncdu will work) and produce a display similar to ncdu
create a simple bash script in ~/tmp/xdg-open which contains basically echo "$1" > ~/tmp/gdu.out; make it executable
run PATH=$HOME/tmp:$PATH gdu -f restic.json
select the file or dir you want and hit o (in gdu that runs xdg-open on the file, but we mangled the PATH so it will run our script instead)
I don’t know why, but every time I restic ls (snapshot-ID) | fzf -i for some reason it freezes and never works. I have to restic ls (snapshot-ID) > files.txt then cat files.txt | fzf -i which makes no sense but it’s the only way I can get it to work.
I mostly like NCDU a little better because you can walk the tree. It’s not just search, it’s seeing the heirarchy.
That trick does work, though! ChatGPT led me to try something similar, but yes it is kludgy haha
A bit off topic but… can anyone confirm ‘restic ls | fzf’ works on MacOS? I swear it hangs on even the tiniest of snapshots on all my Macs unless I dump it to a text file then ‘cat’ it to fzf.
Honestly that would be good enough for me, though I do like the tree navigation of NCDU
Ah yes, normally that would be my go-to as well - though presently it’s a little broken under MacOS Sonoma. On top of that, my repository is 10TB and struggles to mount with my measly 16GB of RAM. And other times I’m operating solely over SSH, to boot. That’s mostly why it comes to mind haha