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

Can i archive selected files in vifm?

1 Answer

+1 vote

For example, you can define zip command in your vifmrc file (the check is to do nothing if you forget to specify name):

command! zip if [ -n "%a" ]; then
           \     zip -r '%a.zip' %f;
           \ fi

Then do the selection and run

:zip archive-name
edited by

Just to expand this based on issue 709

Here is a version that archives:

  • all selected files to %a.zip if %a is provided
  • all selected files to directory_name.zip if no %a is provided and multiple files are selected
  • the current file to file_name.zip if a single file is selected or no file is selected.
command! zip if [ -n "%a" ]; then
           \     zip -r '%a.zip' %f;
           \ elseif [ "%c" = "%f" ]; then
           \     zip -r %c.zip %c;
           \ else
           \     zip -r %d:t.zip %f;
           \ fi

Changed %c == %f to "%c" = "%f" or it probably won't work due to comparing one value to many.