Difference between revisions of "How to copy path to current file/directory to system clipboard"

From Vifm Wiki
Jump to navigation Jump to search
(Initial version of the page)
 
(add filename w\o path)
Line 13: Line 13:
 
" yank current file path into the clipboard
 
" yank current file path into the clipboard
 
nnoremap yf :!echo -n %c:p | xclip %i<cr>
 
nnoremap yf :!echo -n %c:p | xclip %i<cr>
 +
 +
" yank current filename w\o path into the clipboard                                                                               
 +
nnoremap yn :!echo -n %c | xclip %i<cr>                                                                                           
 
</source>
 
</source>
  

Revision as of 20:13, 27 August 2014

This is a matter of communicating current path from Vifm to system buffer via external command.

On *nix like operating systems using xclip

Commands to copy full paths to current directory and currently selected file could look like this:

" yank current directory path into the clipboard
nnoremap yd :!echo -n %d | xclip %i<cr>

" yank current file path into the clipboard
nnoremap yf :!echo -n %c:p | xclip %i<cr>

" yank current filename w\o path into the clipboard                                                                                
nnoremap yn :!echo -n %c | xclip %i<cr>

On Windows using clip

Similar commands, but each has two versions for different types of slashes.

" yank current directory path to Windows clipboard with forward slashes
nnoremap yp :!echo %"d:gs!\!/! %i | clip<cr>

" yank current directory path to Windows clipboard with backward slashes
nnoremap yP :!echo %"d %i | clip<cr>

" yank path to current file to Windows clipboard with forward slashes
nnoremap yf :!echo %"f:gs!\!/! %i | clip<cr>

" yank path to current directory to Windows clipboard with backward slashes
nnoremap yF :!echo %"f %i | clip<cr>