diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 515d17a19..7219b3695 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -32,6 +32,7 @@ Added in rapid mode. - New `{clipboard}` and `{primary}` replacements for the commandline which replace the `:paste` command. +- New `:window-only` command to close all other windows. Changed ~~~~~~~ diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 2964b6113..44fdeff5b 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -769,6 +769,13 @@ class CommandDispatcher: raise cmdexc.CommandError("Can't zoom {}%!".format(level)) message.info(self._win_id, "Zoom level: {}%".format(level)) + @cmdutils.register(instance='command-dispatcher', scope='window') + def window_only(self): + """Close all windows except for the current one.""" + for win_id, window in objreg.window_registry.items(): + if win_id != self._win_id: + window.close() + @cmdutils.register(instance='command-dispatcher', scope='window') def tab_only(self, left=False, right=False): """Close all tabs except for the current one. diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 41b2e06f7..77e00d7a8 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -525,6 +525,20 @@ Feature: Various utility commands. - data/hints/link_blank.html - data/hello.txt (active) + @no_xvfb + Scenario: :window-only + Given I run :tab-only + And I open data/hello.txt + When I open data/hello2.txt in a new tab + And I open data/hello3.txt in a new window + And I run :window-only + Then the session should look like: + windows: + - tabs: + - active: true + history: + - url: http://localhost:*/data/hello3.txt + ## Variables Scenario: {url} as part of an argument