lf icon indicating copy to clipboard operation
lf copied to clipboard

sudo cp file/folder

Open se7en-x230 opened this issue 3 years ago • 4 comments

I fail to get a command of sudo cp -r working. Nicest solution would be to yank a file and past it with sudo

Any nicer suggestions?

This is working but I have to mark the file with space and can't use yank

`# {{{ <<<<<<<<<<<<<<<<<<<<<<<<< sudo paste "ps" <<<<<<<<<<<<<<<<<<<<<<<<<< cmd sudocp ${{ sudo cp -r "$fx" . }} ##------------------- map ps sudocp Paste file with sudo #-------------------

`

se7en-x230 avatar Aug 18 '22 02:08 se7en-x230

https://github.com/gokcehan/lf/wiki/Tips contains several examples of a custom paste command.

lahwaacz avatar Aug 18 '22 05:08 lahwaacz

Thanks I read that before. I manage to sudo cp a selected $fs item but not a yanked (I guess $@)

se7en-x230 avatar Aug 18 '22 12:08 se7en-x230

Search for the tips handling ~/.local/share/lf/files

lahwaacz avatar Aug 18 '22 18:08 lahwaacz

Thanks I give up. "$fs" is not really what I want but it works ... so whatever. "$@" asks for passwd but doesn't take it and asks again and again ...

se7en-x230 avatar Aug 19 '22 02:08 se7en-x230

Try this (adapted from the tips):

cmd sudocp ${{
    set -- $(cat ~/.local/share/lf/files)
    mode="$1"
    shift
    case "$mode" in
        copy) sudo cp -rn -- "$@" .;;
        move) sudo mv -n -- "$@" .;;
    esac
    rm ~/.local/share/lf/files
    lf -remote "send clear"
}}

This command uses sudo to copy/move your yanked/cut files.

en0mem avatar Dec 30 '22 17:12 en0mem

Thanks

se7en-x230 avatar Jan 01 '23 11:01 se7en-x230