17

Whenever I copy-paste a file path I get this:

x-special/nautilus-clipboard copy 
file://<file-path>

instead of just

<file-path>

2 Answers2

10

Unbelievably, however inconveniencing it is, this bug is more than 2 years old, and hasn't been fixed yet. The best workaround for me has been the Nautilus script with a keyboard shortcut described by Filip Tack here.

First, install xsel with apt install xsel.

Then, on ~/.local/share/nautilus/scripts create a file (you can choose any name you want, but let's suppose you call it "copypath") with the following line of code. It copies to the clipboard the path of your selection in Nautilus:

echo -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | tr -d '\n' | xsel -b -i

To run it, right-click on the file of interest and go to Scripts, copypath. Then you can paste the path anywhere.

But repeating this many times is unwieldy. You can define a keyboard shortcut for a quicker copy:

Create a file .config/nautilus/scripts-accels if it does not yet exist, and add the line

<Control><Shift>c copypath

to bind the script to c in Nautilus.

The scripts works immediately, but the shortcut needs logging back in.

ARX
  • 635
  • 6
  • 14
  • 2
    When I right-click on the file on interest it doesn't have an option called "scripts" – matohak Dec 30 '20 at 10:55
  • 4
    I don't know if you figured it out, but I had to chmod +x so that the copypath file was executable before it was counted as a script, and the scripts option doesn't show up until you have at least one. – SilentLupin Feb 02 '21 at 20:21
  • 2
    Thank you for the workaround. For reference and to direct upvotes so as to stress the importance of this issue, here is the current issue blocking all the fixes (it's not even a nautilus issue but has to do with the desktop icons plugin): https://gitlab.gnome.org/World/ShellExtensions/desktop-icons/-/merge_requests/186. Please add your "thumbs up" there. – Greg Kramida Feb 18 '21 at 13:08
  • 1
    I have to use `echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | head -c -2 | xsel -b -i` to remove the two trailing newlines at the end of the variable. – matthieu Apr 27 '21 at 02:20
  • Hideous bug, fantastic workaround. – Stromael Aug 27 '21 at 08:18
4

This is something gnome is well aware of and it apparently has to do with an extension (I think, it's complicated), you can follow this issue on their gitlab site. I'll agree it's very annoying and I hope a fix is up soon.

Eman
  • 185
  • 1
  • 3
  • 13