diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index d3819741e..7d70614d3 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -20,6 +20,7 @@ |<>|Open the last/[count]th download. |<>|Remove the last/[count]th download from the list. |<>|Retry the first failed/[count]th download. +|<>|Compose a url in an external editor and navigate to it. |<>|Send a fake keypress or key string to the website or qutebrowser. |<>|Go forward in the history of the current tab. |<>|Toggle fullscreen mode. @@ -223,6 +224,21 @@ Retry the first failed/[count]th download. ==== count The index of the download to retry. +[[edit-url]] +=== edit-url +Syntax: +:edit-url [*--bg*] [*--tab*] [*--window*] ['url']+ + +Open a URL in an external editor and navigate to it upon closing the editor. + +==== optional arguments +* +'url'+: A URL to pre-populate the editor with; defaults to the current URL. +* +*-b*+, +*--bg*+: Open in a new background tab. +* +*-t*+, +*--tab*+: Open in a new tab. +* +*-w*+, +*--window*+: Open in a new window. + +==== count +The tab index to open the URL in. + [[fake-key]] === fake-key Syntax: +:fake-key [*--global*] 'keystring'+ diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 3cae6941c..e65676bb3 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1847,3 +1847,26 @@ class CommandDispatcher: """Clear remembered SSL error answers.""" nam = self._current_widget().page().networkAccessManager() nam.clear_all_ssl_errors() + + @cmdutils.register(instance='command-dispatcher', scope='window') + def edit_url(self, url=None, bg=False, tab=False, window=False, count=None): + """Navigate to a url formed in an external editor. + + The editor which should be launched can be configured via the + `general -> editor` config option. + + Args: + url: URL to edit; defaults to the current page url. + bg: Open in a new background tab. + tab: Open in a new tab. + window: Open in a new window. + count: The tab index to open the URL in, or None. + """ + ed = editor.ExternalEditor(self._win_id, self._tabbed_browser) + + # Passthrough for openurl args (e.g. -t, -b, -w) + ed.editing_finished.connect( + functools.partial(self.openurl, + bg=bg, tab=tab, window=window, count=count)) + + ed.edit(url or self._current_url().toString())