Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by
edited by

I already tried a command workaround:

command! cplink cp -rL %d/%f %D

But maybe there is a way to change the default copy behavior?

1 Answer

0 votes
by

But maybe there is a way to change the default copy behavior?

Nothing builtin for that. Symlinks are always copied as symlinks. You can try mapping copying like

nnoremap <silent> yd gfyy<c-o>

Where "yd" is for "yank deep". It's not optimal, but seems to work.

by

Yes, this would work for how I put the initial question. Maybe I need to explain, where my motivation comes from:
I am often in a situation, where I work with remote machines. Vifm allows for convenient remote connections via sshfs. Typically, on the remote machine I am faced with some kind of "data-versioning-control", i.e. files are neatly sitting in a project folder, but are only represented by symlinks, pointing to some central location with a hash-value naming convention. For instance:
interesting_file.ext -> /path/to/central/folder/46/8a8b8c98f89d8989e
Hence I used the cp -Lr approach to dereference the symbolic link and keep the name of the link-file. Your proposal works fine, however, it will take over the actual file name, which is in this case a hash-value.

by

Right, abusing yanking won't work then, but we can try abusing putting instead:

nnoremap <silent> pd :!cp -rL %r" %d<cr>
by

This will likely fail if the list of the paths exceeds the maximum supported length of the arguments. Is there any better solution?

by

Is there any better solution?

Probably, no, because it needs piping contents of registers (requested here). Although I'm not sure if the limit applies to builtin commands, otherwise a loop can be a workaround (see the linked issue).

Just checked and -L of cp is actually in POSIX, so it can be assumed to be present, and therefore a flag could be added to copy link's destination instead of the link itself.

by

There will be :put -deep and :copy -deep in v0.15 (commit).

...