$ show Stunkymonkey/nautilus-open-any-terminal
This is a Nautilus/Caja file manager extension written in Python that adds a context menu entry to open a terminal emulator in the current directory. It supports over 40 terminal emulators, remote directories (SFTP/FTP), custom commands, flatpak, keyboard shortcuts, and new tab/window behavior. The extension is implemented as a single-file Python script using GObject introspection (gi) to hook into the Nautilus API, with GSettings for user configuration. It provides localized strings via gettext translations. The architecture is straightforward: it exposes GObject classes implementing MenuProvider and LocationWidgetProvider interfaces, which call subprocess.Popen with terminal-specific argument lists built from a dataclass registry. Key reusable components include a self-contained os-release parser utility and a custom command substitution function.
The LLM identified 2 files worth highlighting for reuse:
The read_os_release() function parses /etc/os-release and /usr/lib/os-release files. It is a self-contained generator that handles quoted values using ast.literal_eval and skips comments and blank lines. This pattern is reusable in any Linux application needing distribution ID detection without external dependencies.
The parse_custom_command() function substitutes each '%s' in a command template with a given data string (or shlex-joined list) and splits the result into arguments using shlex.split. It is self-contained, handles edge cases, and can be reused in any project requiring customizable command-line construction with substitution.