- IMPORTANT
- What is this?
- Installation
- Customization
- Headline face
- Tab Styles
- Tab height
- Tab icons
- Plain icons
- Graying out icons
- Selected tab bar
- Customize the close button
- Customize the modified marker
- Change the font family and height
- Disable centaur-tabs in selected buffers
- Buffer groups
- Show buffer groups names instead of buffer names in tabs
- Enable Vim like tab motions
- Prevent the access to specified buffers
- Tab cycling
- Buffer reordering (thanks to jixiuf)
- Alphabetical buffer reordering (thanks to cburroughs)
- Helm integration
- Ivy integration
- Projectile integration
- Mouse support (thanks to alvarogonzalezsotillo)
- Key bindings
- TO DO
- My personal configuration
- Useful commands
- Known supported theme plugins
- How to contribute
Now centaur-tabs
supports Emacs 27’s native tab-line
and it uses it to render the tabs. Previously the tabs were rendered in the header-line
. Although Emacs 27’s tab-line workspaces are not yet supported, the feature will be implemented in a near future.
This projects aims to become an aesthetic, functional and efficient tabs plugin for Emacs with a lot of customization options. Although this is a fork from awesome-tab (that I forked with the permission from the author and it’s also based on tabbar) it’s been heavily modified so now it may be considered a different package. Also this package integrates functionalities from tabbar-ruler.
It currently looks like this (although there’s a ton of possible configurations):
You can download this package from MELPA. This is a basic use-package
configuration:
(use-package centaur-tabs
:demand
:config
(centaur-tabs-mode t)
:bind
("C-<prior>" . centaur-tabs-backward)
("C-<next>" . centaur-tabs-forward))
Or if you use require:
(require 'centaur-tabs)
(centaur-tabs-mode t)
(global-set-key (kbd "C-<prior>") 'centaur-tabs-backward)
(global-set-key (kbd "C-<next>") 'centaur-tabs-forward)
This package is heavily customizable, with many options available to the user. Here are some of them:
You can make the headline face match the centaur-tabs-default face. This makes the tabbar have an uniform appearance. In your configuration use the following function:
(centaur-tabs-headline-match)
To change the tab style, modify the centaur-tabs-style variable like this:
(setq centaur-tabs-style "bar")
The options available are:
- “alternate”
- “bar”
- “box”
- “chamfer”
- “rounded”
- “slant”
- “wave”
- “zigzag”
To change the tab height do
(setq centaur-tabs-height 32)
To display themed icons from all the icons
(setq centaur-tabs-set-icons t)
To make icons plain (same color as tabs’ text):
(setq centaur-tabs-plain-icons t)
To gray out icons for the unselected tabs:
(setq centaur-tabs-gray-out-icons 'buffer)
To display a colored bar at the left of the selected tab
(setq centaur-tabs-set-bar 'left)
To display an overline over the selected tab:
(setq centaur-tabs-set-bar 'over)
To display an underline over the selected tab:
(setq centaur-tabs-set-bar 'under)
;; Note: If you're not using Spacmeacs, in order for the underline to display
;; correctly you must add the following line:
(setq x-underline-at-descent-line t)
The color can be customized via the centaur-tabs-active-bar-face face.
To disable the close button
(setq centaur-tabs-set-close-button nil)
To change the displayed string for the close button
(setq centaur-tabs-close-button "X")
Also there are two faces to customize the close button string: centaur-tabs-close-unselected and centaur-tabs-close-selected
To display a marker indicating that a buffer has been modified (atom-style)
(setq centaur-tabs-set-modified-marker t)
To change the displayed string for the modified-marker
(setq centaur-tabs-modified-marker "*")
Also there are two faces to customize the close button string: centaur-tabs-modified-marker-unselected and centaur-tabs-modified-marker-selected
To easily customize the tabs font by changing it’s height and font family use the following function:
(centaur-tabs-change-fonts "arial" 160)
To disable the tabs in a buffer just add a hook to the centaur-tabs-local-mode
function like this:
(add-hook 'dired-mode-hook 'centaur-tabs-local-mode)
or with use-package
:
(use-package centaur-tabs
...
:hook
(dired-mode . centaur-tabs-local-mode)
...)
To customize the way that the buffers are grouped modify the centaur-tabs-buffer-groups
function like this:
(defun centaur-tabs-buffer-groups ()
"`centaur-tabs-buffer-groups' control buffers' group rules.
Group centaur-tabs with mode if buffer is derived from `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'.
All buffer name start with * will group to \"Emacs\".
Other buffer group by `centaur-tabs-get-group-name' with project name."
(list
(cond
((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode
)))
"Emacs")
((derived-mode-p 'prog-mode)
"Editing")
((derived-mode-p 'dired-mode)
"Dired")
((memq major-mode '(helpful-mode
help-mode))
"Help")
((memq major-mode '(org-mode
org-agenda-clockreport-mode
org-src-mode
org-agenda-mode
org-beamer-mode
org-indent-mode
org-bullets-mode
org-cdlatex-mode
org-agenda-log-mode
diary-mode))
"OrgMode")
(t
(centaur-tabs-get-group-name (current-buffer))))))
If you want your tabs to display buffer groups names instead of buffer names you can put the following in your configuration:
(setq centaur-tabs--buffer-show-groups t)
You can toggle between the two options interactively with the (centaur-tabs-toggle-groups)
command.
To enable Vim like tab changing binds
(define-key evil-normal-state-map (kbd "g t") 'centaur-tabs-forward)
(define-key evil-normal-state-map (kbd "g T") 'centaur-tabs-backward)
or with use-package
:
(use-package centaur-tabs
...
:bind
(:map evil-normal-state-map
("g t" . centaur-tabs-forward)
("g T" . centaur-tabs-backward))
...)
You can prevent the access to some buffers via tab motions changing the following function like this:
(defun centaur-tabs-hide-tab (x)
"Do no to show buffer X in tabs."
(let ((name (format "%s" x)))
(or
;; Current window is not dedicated window.
(window-dedicated-p (selected-window))
;; Buffer name not match below blacklist.
(string-prefix-p "*epc" name)
(string-prefix-p "*helm" name)
(string-prefix-p "*Helm" name)
(string-prefix-p "*Compile-Log*" name)
(string-prefix-p "*lsp" name)
(string-prefix-p "*company" name)
(string-prefix-p "*Flycheck" name)
(string-prefix-p "*tramp" name)
(string-prefix-p " *Mini" name)
(string-prefix-p "*help" name)
(string-prefix-p "*straight" name)
(string-prefix-p " *temp" name)
(string-prefix-p "*Help" name)
(string-prefix-p "*mybuf" name)
;; Is not magit buffer.
(and (string-prefix-p "magit" name)
(not (file-name-extension name)))
)))
The function shown is the default function from the centaur-tabs
configuration, adding the (string-prefix-p "*mybuf" name)
part to prevent the access to every buffer with its name ending in “mybuf”. You can either add this function as it is to preserve centaur-tabs
default filters and add any Boolean function that you want to filter your buffers (i.e string-prefix-p
or string-suffix-p
) like in this example with the “mybuf” line, or completely override the function with your custom filters if you completely know what you’re doing.
The default behaviour from the centaur-tabs-forward/backward
functions is to go through all the tabs in the current group and then change the group. If this is something that is to desired to be changed the centaur-tabs-cycle-scope
custom must be changed like this:
(setq centaur-tabs-cycle-scope 'tabs)
There are three options:
- ‘default: (Already described)
- ‘tabs: Cycle through visible tabs (that is, the tabs in the current group)
- ‘groups: Navigate through tab groups only
To enable an automatic buffer reordering function use the following function in your configuration:
(centaur-tabs-enable-buffer-reordering)
;; When the currently selected tab(A) is at the right of the last visited
;; tab(B), move A to the right of B. When the currently selected tab(A) is
;; at the left of the last visited tab(B), move A to the left of B
(setq centaur-tabs-adjust-buffer-order t)
;; Move the currently selected tab to the left of the the last visited tab.
(setq centaur-tabs-adjust-buffer-order 'left)
;; Move the currently selected tab to the right of the the last visited tab.
(setq centaur-tabs-adjust-buffer-order 'right)
This works the following way. If there’s a certain group of tabs like the following:
tab1.el | tab2.js | tab3.c | tab4.py |
If you’re in a tab and change to another tab in the group (via Ido, Ivy or Helm) the new tab will move to the right side of the tab you were, so if you’re on tab1.el
and you clicked tab4.py
the tabs order will be the following:
tab1.el | tab4.py | tab2.js | tab3.c |
And then if you were on tab4.py
and changed to tab2.js
, the tabs order will be the following:
tab1.el | tab4.py | tab2.js | tab3.c |
the order doesn’t change, because the tabs are already next to each other.
And now if you were on tab2.js
and changed to tab1.el
, the tabs order will be the following:
tab4.py | tab1.el | tab2.js | tab3.c |
This functionality doesn’t take effect when using centaur-tabs motion functions like centaur-tabs-backward/forward
.
To enable an automatic alpabetical buffer reordering, put the following lines in your configuration.
(centaur-tabs-enable-buffer-alphabetical-reordering)
(setq centaur-tabs-adjust-buffer-order t)
This function will trigger each time a non centaur-tabs motion command is executed. NOTE: Given the Emacs behaviour when opening a new file is a little bit funky, when a new tab is opened, it will always be placed at the right of the last visited buffer. This behaviour needs to be investigated in order to see if a possible solution exists.
You can integrate Helm with centaur-tabs for changing tab-groups. Just add helm-source-centaur-tabs-group in helm-source-list. Then you’ll be able to use (centaur-tabs-build-helm-source)
function and bind it to any key you want. (I’m not a Helm user so I’ll not be able to solve problems related to this).
You can integrate Ivy with centaur-tabs for changing tab-groups. Just use the (centaur-tabs-counsel-switch-group)
and bind it to any key you want.
You can group your tabs by Projectile’s project. Just use the following function in your configuration:
(centaur-tabs-group-by-projectile-project)
This function can be called interactively to enable Projectile grouping. To go back to centaur-tabs’s user defined (or default) buffer grouping function you can interactively call:
(centaur-tabs-group-buffer-groups)
- Just click in a tab to change the buffer of the current window.
- Click the mouse wheel to close a buffer.
- Right click on empty space to show a tab groups popup.
- Right click on a tab to show a context menu. The options are inspired by the options provided by VSCode.
- Use the mouse wheel to invoke
centaur-tabs-backward/forward
. - Set the
centaur-tabs-show-navigation-buttons
custom variable tot
to display cool navigation buttons. With the CTRL key, the left and right navigation buttons will move the tabs through the tab line.
If you want to enable a series of key bindings with different tab managing functions, put the following in your configuration before the package is loaded (if you use use-package
, this should go in the :init
section):
(setq centaur-tabs-enable-key-bindings t)
The key bindings enabled will be the following:
C-c C-left
: (centaur-tabs-backward)C-c C-right
: (centaur-tabs-forward)C-c C-up
: (centaur-tabs-backward-group)C-c C-down
: (centaur-tabs-forward-group)C-c C-f10
: (centaur-tabs-local-mode)C-c C-5
: (centaur-tabs-extract-window-to-new-frame)C-c C-k
: (centaur-tabs-kill-other-buffers-in-current-group)C-c C-o
: (centaur-tabs-open-in-external-application)C-c C-d
: (centaur-tabs-open-directory-in-external-application)
- [X] Integrate all-the-icons
- [X] Improve all the icons placing
- [X] Fix all the icons background
- [X] Add selected, unselected, selected-modified and unselected-modified faces
- [X] Make function to inherit tabbar faces
- [X] Group tabs by projectile’s project (was already implemented but not for projectile)
- [X] Create PR to different theme packages for this package
- [X] Add modified marker icon option
- [X] Add sideline for selected tab (atom style)
- [X] Add overline for selected tab (atom style). It’s easy to add to the text, but not to the icon, so for any who figures it out a PR is welcome.
- [ ] Add easy tab style configuration function. (Atom, Sublime, VS Code… like
(centaur-tabs-tab-theme "atom")
) - [X] Make icon insert after the separator
- [X] Add a customizable close button
- [X] Explore if
after-modifying-buffer
function can be improved - [X] Fix messages buffer icon an FontAwesome errors
- [X] Check for Elscreen compatibility
- [X] Add this package to MELPA
- [X] Make a configuration to display buffer groups names instead of buffer names in tabs
- [ ] Add full evil-mode support with tab commands
My personal configuration for reference:
(use-package centaur-tabs
:load-path "~/.emacs.d/other/centaur-tabs"
:config
(setq centaur-tabs-style "bar"
centaur-tabs-height 32
centaur-tabs-set-icons t
centaur-tabs-set-modified-marker t
centaur-tabs-show-navigation-buttons t
centaur-tabs-set-bar 'under
x-underline-at-descent-line t)
(centaur-tabs-headline-match)
;; (setq centaur-tabs-gray-out-icons 'buffer)
;; (centaur-tabs-enable-buffer-reordering)
;; (setq centaur-tabs-adjust-buffer-order t)
(centaur-tabs-mode t)
(setq uniquify-separator "/")
(setq uniquify-buffer-name-style 'forward)
(defun centaur-tabs-buffer-groups ()
"`centaur-tabs-buffer-groups' control buffers' group rules.
Group centaur-tabs with mode if buffer is derived from `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'.
All buffer name start with * will group to \"Emacs\".
Other buffer group by `centaur-tabs-get-group-name' with project name."
(list
(cond
;; ((not (eq (file-remote-p (buffer-file-name)) nil))
;; "Remote")
((or (string-equal "*" (substring (buffer-name) 0 1))
(memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode
)))
"Emacs")
((derived-mode-p 'prog-mode)
"Editing")
((derived-mode-p 'dired-mode)
"Dired")
((memq major-mode '(helpful-mode
help-mode))
"Help")
((memq major-mode '(org-mode
org-agenda-clockreport-mode
org-src-mode
org-agenda-mode
org-beamer-mode
org-indent-mode
org-bullets-mode
org-cdlatex-mode
org-agenda-log-mode
diary-mode))
"OrgMode")
(t
(centaur-tabs-get-group-name (current-buffer))))))
:hook
(dashboard-mode . centaur-tabs-local-mode)
(term-mode . centaur-tabs-local-mode)
(calendar-mode . centaur-tabs-local-mode)
(org-agenda-mode . centaur-tabs-local-mode)
(helpful-mode . centaur-tabs-local-mode)
:bind
("C-<prior>" . centaur-tabs-backward)
("C-<next>" . centaur-tabs-forward)
("C-c t s" . centaur-tabs-counsel-switch-group)
("C-c t p" . centaur-tabs-group-by-projectile-project)
("C-c t g" . centaur-tabs-group-buffer-groups)
(:map evil-normal-state-map
("g t" . centaur-tabs-forward)
("g T" . centaur-tabs-backward)))
Centaur tabs has plenty of useful commands for manipulating tabs and tab groups. Some of them are:
(centaur-tabs-kill-all-buffers-in-current-group)
: Kills all buffers in current tab group.(centaur-tabs-kill-match-buffers-in-current-group)
: Kills all buffers in current tab group with the same extension as the current buffer.(centaur-tabs-keep-match-buffers-in-current-group)
: Asks for a file extension and kills all the buffers with a different extension.(centaur-tabs-kill-other-buffers-in-current-group)
: Kills all buffers in current tab group except the current buffer.(centaur-tabs-kill-unmodified-buffers-in-current-group)
: Kills all buffers in current tab group that are unmodified.(centaur-tabs-select-beg-tab)
: Selects the first tab of the group.(centaur-tabs-select-end-tab)
: Selects the last tab of the group.(centaur-tabs-forward-group)
: Go to the next tab group.(centaur-tabs-backward-group)
: Go to the previous tab group.
- Atom One Dark Theme
- Base16
- Chocolate Theme
- Doom Themes
- Kaolin Themes
- Spacemacs Theme
- Tron Legacy
- Wilmersdorf Theme
- Zenburn
You can contribute by forking the repo and then creating a pull request with the changes you consider will improve the package. There’s a TO DO list with wanted features so you can start from there. I’ll be glad to receive help. Please try to keep the code as clear and documented as possible.