diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 2b7b90ac5..a7c6633a1 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -282,6 +282,23 @@ class CommandDispatcher: diag.setAttribute(Qt.WA_DeleteOnClose) diag.open(lambda: tab.print(diag.printer())) + @cmdutils.register(instance='command-dispatcher') + def tab_clone(self, bg=False): + """Duplicate the current tab. + + Args: + bg: Open in a background tab. + + Return: + The new QWebView. + """ + curtab = self._current_widget() + tabbed_browser = objreg.get('tabbed-browser') + newtab = tabbed_browser.tabopen(background=bg, explicit=True) + history = qtutils.serialize(curtab.history()) + qtutils.deserialize(history, newtab.history()) + return newtab + @cmdutils.register(instance='command-dispatcher') def back(self, count=1): """Go back in the history of the current tab. diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index e43ab598a..2528375c0 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -887,6 +887,7 @@ KEY_DATA = collections.OrderedDict([ ('tab-move +', ['gr']), ('tab-next', ['J']), ('tab-prev', ['K']), + ('tab-clone', ['gC']), ('reload', ['r']), ('back', ['H', '']), ('forward', ['L']),