Tab groups for the tab bar.
This package provides the means to work with and to customize the appearance of named groups of tabs in Emacs 27 and higher (see below for screenshots and commands).
If you use MELPA, an easy way to install this package is via
package-install
. Alternatively, download tab-bar-groups.el
, put it
in your load-path
and require
it. Finally, use
(tab-bar-groups-activate)
or M-x tab-bar-groups-activate
to turn on
the provided features.
If you use both MELPA and use-package
, you can use this, too:
(use-package tab-bar-groups
:ensure
:config
(tab-bar-groups-activate))
Emacs 27, or Emacs 28 without tab-bar-format-tabs-groups
in
tab-bar-format
: Showing a bunch of tabs in three groups Emacs
,
News
, tbg
, with init.el
being the current tab and Emacs
being
the current group. Note that all tabs of all groups are visible. Also
note that the *scratch*
tab (unstyled) is not part of a group.
Emacs 28 with tab-bar-format-tabs-groups
in tab-bar-format
: Showing
the same groups and tabs as above. Note that
tab-bar-format-tabs-groups
hides tabs in inactive groups.
The faces applied to the current/other tabs and groups are fully customizable.
Table of available commands and their description.
Command | Description |
---|---|
tab-bar-groups-new-tab | Create a new tab in the current group.¹ |
tab-bar-groups-duplicate-tab | Duplicate current tab in its group.¹ |
tab-bar-groups-change-tab-group | Change the group of the current tab (query name w/ completion).¹ |
tab-bar-groups-rename-group | Rename the group that the current tab belongs to (query name w/ completion). |
tab-bar-groups-eject-tab | Eject the current tab from its group. |
tab-bar-groups-close-group-tabs | Close all tabs of the current group.¹ |
tab-bar-groups-regroup-tabs | Re-order tabs so that all tabs of each group are next to each other. |
(1) Required in Emacs 27 only. Emacs 28 provides commands with similar functionality natively.
Note that this package doesn’t bind any keys by itself.
In my local configuration, I added bindings for the above commands to
the pre-existing keymap for tab-related commands (C-x t
):
(use-package tab-bar-groups
:ensure
:demand
:config
(tab-bar-groups-activate)
:bind (:map tab-prefix-map
("g0" . tab-bar-groups-close-group-tabs)
("g2" . tab-bar-groups-new-tab)
("ga" . tab-bar-groups-change-tab-group)
("gg" . tab-bar-groups-regroup-tabs)
("gd" . tab-bar-groups-duplicate-tab)
("gk" . tab-bar-groups-eject-tab)
("gr" . tab-bar-groups-rename-group)))
This package was built with extensibility in mind. In fact, it’s an extraction of a bigger suite of features that I use locally to enable a “one tab group per project” workflow.
If you want to change how new tabs pick their appearance/color, how grouped tabs render in the tab bar or what happens after a tab’s group assignment has changed, have a look at the various extension points of this package:
tab-bar-groups-appearances
tab-bar-groups-colors
tab-bar-groups-pick-group-appearance-function
tab-bar-groups-style-tab-name-functions
tab-bar-groups-tab-post-change-group-functions
(an abnormal hook)
For example, to keep all tabs of each group next to each other at all times:
(add-hook 'tab-bar-groups-tab-post-change-group-functions #'tab-bar-groups-regroup-tabs)
This package provides a range of helper functions that you can use to find out about existing groups, their names, etc.
This package provides an integration with the tab-bar-echo-area package.
Tabs and tab groups are rendered like in the tab bar (that is,
tab-bar-format
settings apply here as well).
After both packages have been loaded, use
(tab-bar-groups-activate-for-tab-bar-echo-area)
to enable it.
(with-eval-after-load 'tab-bar-echo-area
(tab-bar-groups-activate-for-tab-bar-echo-area))
This package provides an integration with the project-mode-line-tag package. It applies the current tab bar group’s color to the project tag in the mode line.
After both packages have been loaded, use
(tab-bar-groups-activate-for-project-mode-line-tag)
to enable it.
(with-eval-after-load 'project-mode-line-tag
(tab-bar-groups-activate-for-project-mode-line-tag))
- project-tab-groups to enhance the Emacs built-in project.el library to support keeping projects isolated in named tab groups (requires Emacs 28).