diff --git a/TODO b/TODO index 293093d2a..2e4404d1a 100644 --- a/TODO +++ b/TODO @@ -284,9 +284,6 @@ Open quickmark in a new tab (command tab_quickmark, aliases: tabqmarks). tab-handling ------------ -co -Close all tabs except for the current one (command only). - [n]T Focus nth tab, first tab if n is omitted or last tab if n is 0. (command focus_tab, aliases: tab). diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index a7a4d1a18..5ddfa4633 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -547,6 +547,7 @@ DATA = OrderedDict([ ('gO', 'tabopencur'), ('ga', 'tabopen about:blank'), ('d', 'tabclose'), + ('co', 'only'), ('J', 'tabnext'), ('K', 'tabprev'), ('r', 'reload'), diff --git a/qutebrowser/widgets/_tabbedbrowser.py b/qutebrowser/widgets/_tabbedbrowser.py index c116475e6..038f5d5b9 100644 --- a/qutebrowser/widgets/_tabbedbrowser.py +++ b/qutebrowser/widgets/_tabbedbrowser.py @@ -248,6 +248,14 @@ class TabbedBrowser(TabWidget): elif last_close == 'blank': tab.openurl('about:blank') + @cmdutils.register(instance='mainwindow.tabs') + def only(self): + """Close all tabs except for the current one.""" + for i in range(self.count() - 1): + if i == self.currentIndex(): + continue + self._close_tab(self.widget(i)) + @cmdutils.register(instance='mainwindow.tabs', split=False, name='tabopen') def tabopen_cmd(self, url): """Open a new tab with a given url."""