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.

Copy path of all selected files to clipboard

0 votes
asked Feb 23, 2019 in vifm by anonymous

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
answered Feb 23, 2019 by xaizek
selected Feb 26, 2019 by xaizek
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.

commented Feb 26, 2019 by anonymous

Thank you a lot, it works!

commented Mar 26, 2019 by sitaram

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

commented Mar 26, 2019 by xaizek

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

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.