When using GNOME Files (Nautilus) with GNOME Console, the keyboard shortcut Ctrl+. can be used to launch a terminal in the currently open folder. Equivalent functionality is not available out of the box for the more fully featured GNOME Terminal – GNOME Terminal adds an ‘Open in Terminal’ option to the context menu, but this does not have a keyboard shortcut.
The current standard approach to assigning a keyboard shortcut to open GNOME Terminal is though scripts-accels (example); however, this pollutes the ‘Scripts’ context menu when right-clicking a folder. Previously, it was possible to use [nautilus-python](https://gitla…
When using GNOME Files (Nautilus) with GNOME Console, the keyboard shortcut Ctrl+. can be used to launch a terminal in the currently open folder. Equivalent functionality is not available out of the box for the more fully featured GNOME Terminal – GNOME Terminal adds an ‘Open in Terminal’ option to the context menu, but this does not have a keyboard shortcut.
The current standard approach to assigning a keyboard shortcut to open GNOME Terminal is though scripts-accels (example); however, this pollutes the ‘Scripts’ context menu when right-clicking a folder. Previously, it was possible to use nautilus-python LocationWidgetProvider to customise GNOME Files keyboard shortcuts (example); however, LocationWidgetProvider was removed in Nautilus 43.
The following extension using nautilus-python presents a workaround to add a keyboard shortcut (F4) for launching the terminal, which (unlike using scripts-accels) does not pollute the context menu. The script should be placed at ~/.local/share/nautilus-python/extensions/open-terminal-here.py.
# Copyright (C) 2025 Lee Yingtong Li
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import gi
gi.require_version('Gtk', '4.0') # Not done automatically by nautilus-python
from gi.repository import Nautilus, GObject, Gio, Gtk
import os
from urllib.parse import unquote
class OpenTerminalHereExtension(GObject.GObject, Nautilus.MenuProvider):
def __init__(self):
super().__init__()
# Keep track of current URI for each window
# URI is passed in via get_background_items, but subsequently not accessible from Gtk.Window
self.uri_for_window = {}
# It used to be possible to modify shortcuts directly via Nautilus LocationWidgetProvider
# However in Nautilus 43 this was removed
# https://gnome.pages.gitlab.gnome.org/nautilus-python/nautilus-python-migrating-to-4.html
# Instead, we must find an opportune time to call Gtk functions directly
# Happily, get_background_items is called whenever changing location, switching tabs, etc.
def get_background_items(self, current_folder: Nautilus.FileInfo) -> list[Nautilus.MenuItem]:
windows = set()
# Find current active Gtk.Window
for window in Gtk.Window.get_toplevels():
if window.is_active():
# Create a new Gio.Action
action = Gio.SimpleAction.new('open-terminal', None)
action.connect('activate', self.action_activated)
window.add_action(action)
# Assign keyboard shortcut
window.get_application().set_accels_for_action('win.open-terminal', ['F4'])
# Store current URI
self.uri_for_window[window] = unquote(current_folder.get_uri()[7:])
# Keep track of current windows
windows.add(window)
# Clean up references to old windows
for old_window in set(self.uri_for_window.keys()) - windows:
del self.uri_for_window[old_window]
return []
def action_activated(self, _action, _args):
# Find current active Gtk.Window
for window in Gtk.Window.get_toplevels():
if window.is_active():
if window in self.uri_for_window:
uri = self.uri_for_window[window]
# Launch terminal
os.chdir(uri)
os.system('gnome-terminal')
break
The standard approach using scripts-accels is probably more robust to changes in Nautilus internals and the Gtk API, but the nautilus-python approach has the advantage that it is more configurable.