From 40ae4113618bd39269fdf7a3598a6d1530c0efc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Mon, 19 Jun 2023 16:11:17 +0300 Subject: lf: change way to paste files * Modified the default paste command to use rsync * Added an archive command to paste with rsync with archive flag set (preserve dates, permissions, ownership, etc.) --- dotfiles/.config/lf/lfrc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dotfiles/.config/lf/lfrc b/dotfiles/.config/lf/lfrc index 10a2952..f88c562 100644 --- a/dotfiles/.config/lf/lfrc +++ b/dotfiles/.config/lf/lfrc @@ -93,6 +93,50 @@ cmd soft_link %{{ ln -s $list . }} +cmd paste &{{ + set -- $(cat ~/.local/share/lf/files) + mode="$1" + shift + case "$mode" in + copy) + rsync -rlDvh --ignore-existing --progress -- "$@" . | + stdbuf -i0 -o0 -e0 tr '\r' '\n' | + while IFS= read -r line; do + lf -remote "send $id echo $line" + done + ;; + move) + mv -n -- "$@" . + lf -remote "send $id clear" + ;; + esac + lf -remote "send $id reload" +}} + +cmd archive &{{ + set -- $(cat ~/.local/share/lf/files) + mode="$1" + shift + case "$mode" in + copy) + rsync -avhH --delete --progress -- "$@" . | + stdbuf -i0 -o0 -e0 tr '\r' '\n' | + while IFS= read -r line; do + lf -remote "send $id echo $line" + done + ;; + move) + rsync -avhH --delete --remove-source-files --progress -- "$@" . | + stdbuf -i0 -o0 -e0 tr '\r' '\n' | + while IFS= read -r line; do + lf -remote "send $id echo $line" + done + lf -remote "send $id clear" + ;; + esac + lf -remote "send $id reload" +}} + # Bindings map A rename map c @@ -117,6 +161,7 @@ map Y :yank-path map L $LESSOPEN='| ~/.local/bin/scope %s' less -r $f # open file preview in pager map P hard_link map soft_link +map r archive # Mouse bindings map :dragon -- cgit v1.2.3