Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Is it possible to copy the path of all currently selected files/folders to the clipboard by running a command?

Currently I'm using

nnoremap yf :!echo %c:p | xclip -selection clipboard %i<cr>

but this gives me only the path of one single item (the current one).

1 Answer

0 votes
by
selected by
 
Best answer

If you replace %c with %f

nnoremap yf :!echo %c:p | xclip -selection clipboard %i<cr>

you'll get all files in the selection, but they will be on the same line. You probably want something like this

nnoremap yf :!printf "\n%%s" %f:p | tail -c+2 | xclip -selection clipboard %i<cr>

which will put each path on a separate line.

by

Thank you a lot, it works!

by

Wouldn't %%s\n avoid the need for the tail?

by

Yes, it would, but there is a trailing new line character with %%\n.

...