There are plenty of examples how to copy the "contents" of a file from command line with the help of xclip
or xsel
. What I am looking for is to copy a file from the command line and paste into the file explorer. So I will use a command to copy a file, not only the contents, and use Ctrlv to paste it in UI.
updated
xclip-copyfile
and xclip-pastefile
work close to what I expect, but when I run xclip-copyfil
e, I can only paste with xclip-pastefile
command, not GUI paste.
Best Answer
I use Nautilus, in Ubuntu, as my File Browser, so I can't speak for any other browser.
The way in which Nautilus handles pasting a file via
Ctrl-v
is quite local to Nautilus, ie. Nautilus only recognizes Ctrl-v as paste a file in response to a copy file command which was issued while in nautilus itself. This means that you can't use Ctrl-v to paste a file whose path you copied in another application.However, if it suits you, Ctrl+Shift+v can be bound to a script which runs under
nautilus-scripts-manager
. With this script, you can do pretty much whatever you like.nautilus-scripts-manager
gives you access to some fundamental information about the current directory and which files/directories are selected. One thing I particularly like about "nautilus-scripts" is that it adds its scripts to theFile
menu item (as well as to the context-menu). This allows you to set a key-binding which is local to Nautilus 3 or Nautilus 2.Here is a rough example, using your already mentioned
xclip-pastefiles
example. Note, that as it stands now, it requires that you set up thexclip-copyfiles
before running this Ctrl-Shift-v paste script.Once you have run the setup
xclip-copyfiles
, you need only navigate to a Nautilus window, and selcet the target directory (or a file in that directory) and press your script's keybinding: Ctrl-Shift-v