commit 7d5530d65bea3ccc857acdd27c453684a1bae6f7 parent 9b099e2df61c045bf1453183e7abdae22b930278 Author: Alex Balgavy <a.balgavy@gmail.com> Date: Sun, 6 Sep 2020 10:30:35 +0200 lf: paste-overwrite Former-commit-id: 1a14e6b820b768b09b8fc6e68df1b796208f936b Diffstat:
M | lf/lfrc | | | 23 | +++++++++++++++++++++++ |
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/lf/lfrc b/lf/lfrc @@ -138,6 +138,28 @@ cmd paste %{{ lf -remote 'send clear' }} +# allow overwriting existing files +cmd paste_overwrite %{{ + load=$(lf -remote 'load') + mode=$(echo "$load" | sed -n '1p') + list=$(echo "$load" | sed '1d') + if [ $mode = 'copy' ]; then + if command -v rsync &>/dev/null; then + rsync -ah --progress $list . + else + cp -rf $list . + fi + elif [ $mode = 'move' ]; then + if command -v rsync &>/dev/null; then + rsync -ah --remove-source-files $list . + else + mv $list . + fi + fi + lf -remote 'send load' + lf -remote 'send clear' +}} + # preview the highlighted file with quicklook cmd ql_preview &{{ qlmanage -p "$fx" &> /dev/null; @@ -203,6 +225,7 @@ map Y copy_path map p map pp paste +map po paste_overwrite map pl paste_link map pr paste_rename