gokcehan / lf

Terminal file manager
MIT License
7.8k stars 330 forks source link

[QUESTION] Paste with overwrite for multiple files #1747

Closed TAforever closed 5 months ago

TAforever commented 5 months ago

Hi, can anyone tell me how to edit the paste with overwrite command so that it works for multiple files

    cmd paste-overwrite %{{
             mode=$(head -1 ~/.local/share/lf/files)
             list=$(sed 1d ~/.local/share/lf/files)
             if [ $mode = 'copy' ]; then
                  cp -r $list .
             elif [ $mode = 'move' ]; then
                 mv $list .
             fi
             lf -remote 'send load'
             lf -remote 'send clear'
   }}
DusanLesan commented 5 months ago

That works fine for me. Do you have ifs set to something? Do you get any errors or it just copies single file or it does nothing? What is minimal configuration to reproduce that issue?

TAforever commented 5 months ago

I get an error when I try to overwrite files 1 2 and 3

cp: failed to stat '/home/theodor/Downloads/1'$'\n''/home/theodor/Downloads/2'$'\n''/home/theodor/Downloads/3': No such file or directory

joelim-work commented 5 months ago

I'm guessing word-splitting isn't performed on $list. This can happen if the shell is set to zsh, in which case is it also necessary to add set shellopts '-y'.

TAforever commented 5 months ago

I'm guessing word-splitting isn't performed on $list. This can happen if the shell is set to zsh, in which case is it also necessary to add set shellopts '-y'.

Thank you for solving the problem, setting the set shellopts '-y' parameter did not help, but changing zsh to bash did

TAforever commented 5 months ago

I'm guessing word-splitting isn't performed on $list. This can happen if the shell is set to zsh, in which case is it also necessary to add set shellopts '-y'.

Thank you for solving the problem, setting the set shellopts '-y' parameter did not help, but changing zsh to bash did

The information turned out to be incorrect, I did not notice that I had set shellopts '-eu' and added set shellopts '-y' so your solution turned out to be completely correct