Can I copy a file from one instance of vifm to another?

717 views Asked by At

I have multiple launched instances of vifm. Is it possible to copy a file from one instance to another (using yy)?

Thanks!

2

There are 2 answers

0
xaizek On BEST ANSWER

BEFORE v0.10

No, you can't do this easily. Instances don't share their run-time state (content of registers in this case), so when you yy file in one of them, other instances are not aware of it.

As a workaround for the cases when you really want this:

  1. (in dst instance) Run :write to save current state into vifminfo file.
  2. (in src instance) Do yy and then :write, which will merge states of two instances.
  3. (in dst instance) Run :restart to reload state (this can bring more than just registers) and do p.

It's not really something I'd recommend, but it should work and might be acceptable in some cases.

SINCE v0.10

Now there is 'syncregs' option, which enables one to share registers among instances. Here's its description:

Specifies identifier of group of instances that share registers between each other. When several instances of vifm have this option set to identical value, they automatically synchronize contents of their registers on operations which use them.

So, putting this to your vifmrc should be enough:

set syncregs=general

Or just set the option temporarily when you need the sharing.

1
mrustle On

Define a map to save current file:

nmap Wf :!ls -1 %f | while read f ; do printf ":!cp %%s/%%s %%s\n" %d $f '%%d' ; done > ~/.vifm_tmp <cr> 

And a second mapping that will source the temporary file:

nmap Pf :source ~/.vifm_tmp<cr>

To copy the file: Wf in the first vifm instance then Pf in the second instance. This works with multiple selected (tagged) files but does not work in visual mode.

You can also sync the source directory:

nmap Yd :!printf ":cd %%s\n" %d > ~/.vifm_tmp<cr> 
nmap Pd :source ~/.vifm_tmp <cr>                  

then copy/paste between the panels of the same instance.