From f7e34ea00b1ac401a0bd30eeed11aa2eb215925a Mon Sep 17 00:00:00 2001
From: Luca Bilke <luca@bil.ke>
Date: Thu, 2 May 2024 19:43:30 +0200
Subject: [PATCH] use new trash tool

---
 .config/lf/lfrc | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/.config/lf/lfrc b/.config/lf/lfrc
index e0b95d67..120b5aaa 100644
--- a/.config/lf/lfrc
+++ b/.config/lf/lfrc
@@ -27,12 +27,23 @@ cmd open-with ${{
 }}
 
 cmd trash &{{
-    for f in $fx; do
-        trash-put $f &
-    done
+    trash-cli put $fx
     lf -remote "send load"
 }}
 
+cmd trash-restore ${{
+    fileid=$(
+        trash-cli list "$PWD" |
+            fzf -d '\0' \
+                --with-nth=1 \
+                --nth=1 \
+                --preview='printf "Original path: %s\nInfo path:     %s\nTrashed on:    %s\n" {1} {2} {3}' |
+            cut -d '' -f 2
+    )
+    [ -z "$fileid" ] && exit
+    trash-cli restore $fileid
+}}
+
 cmd lazygit %{{
     dir=$(dirname "$(realpath "${f:-_}")"})
     if ! git --noglob-pathspecs -C $dir status >/dev/null 2>&1; then
@@ -280,7 +291,7 @@ map st :set sortby time; set info time
 map sa :set sortby atime; set info atime
 map sc :set sortby ctime; set info ctime
 map se :set sortby ext; set info
-map <c-t> $trash-restore $PWD
+map <c-t> trash-restore
 map t tag-toggle
 map T trash
 map u :clear; unselect