Skip to content

Instantly share code, notes, and snippets.

@capaj
Created September 24, 2026 11:07
Show Gist options
  • Select an option

  • Save capaj/0f87f3b1211d9c365793d08171b4cf78 to your computer and use it in GitHub Desktop.

Select an option

Save capaj/0f87f3b1211d9c365793d08171b4cf78 to your computer and use it in GitHub Desktop.
Nautilus (GNOME Files) extension: "Copy Full Path" in the file right-click menu
# Adds "Copy Full Path" to the Nautilus (GNOME Files) context menu.
# Multiple selected files are copied as newline-separated paths.
#
# Install:
# sudo apt install python3-nautilus # Fedora: nautilus-python
# mkdir -p ~/.local/share/nautilus-python/extensions
# cp copy_full_path.py ~/.local/share/nautilus-python/extensions/
# nautilus -q
import gi
gi.require_version("Gdk", "4.0")
from gi.repository import Nautilus, GObject, Gdk
def location_string(file):
location = file.get_location()
# Non-local locations (smb://, sftp://, trash://) have no filesystem path.
return location.get_path() or location.get_uri()
def copy_to_clipboard(_menu, text):
Gdk.Display.get_default().get_clipboard().set(text)
def make_item(name, label, files):
text = "\n".join(location_string(f) for f in files)
item = Nautilus.MenuItem(name=name, label=label, icon="edit-copy-symbolic")
item.connect("activate", copy_to_clipboard, text)
return item
class CopyFullPathMenuProvider(GObject.GObject, Nautilus.MenuProvider):
def get_file_items(self, files):
if not files:
return []
label = "Copy Full Path" if len(files) == 1 else "Copy Full Paths"
return [make_item("CopyFullPath::files", label, files)]
def get_background_items(self, folder):
return [make_item("CopyFullPath::folder", "Copy Folder Path", [folder])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment