Created
December 19, 2025 06:33
-
-
Save renegarcia/eb812ac573ed4cedeaaeca0fd728f9cb to your computer and use it in GitHub Desktop.
Open terminal menu for Nautilus aka Gnome Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Add an action to the Nautilus context-menu to open | |
| alacritty terminal. | |
| Author: Rene Garcia | |
| """ | |
| from gi.repository import GObject, Nautilus | |
| import subprocess | |
| class OpenTerminalMenuProvider(GObject.GObject, Nautilus.MenuProvider): | |
| def open_terminal(self, item:Nautilus.MenuItem, current_folder:Nautilus.FileInfo): | |
| cwd = current_folder.get_location().get_path() | |
| subprocess.Popen(['alacritty','--working-directory', cwd]) | |
| def get_background_items(self, current_folder:Nautilus.FileInfo)->list[Nautilus.MenuItem]: | |
| menu_item = Nautilus.MenuItem( | |
| name="OpenTerminalMenuProvider::open", | |
| label="Open py terminal", | |
| ) | |
| menu_item.connect('activate', self.open_terminal, current_folder) | |
| return menu_item, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment