centaur-tabs

Emacs plugin aiming to become an aesthetic, modern looking tabs plugin

Github stars Tracking Chart

#+TITLE: Centaur tabs
#+CREATOR: Emmanuel Bustos T.
#+OPTIONS: toc:nil

[[https://melpa.org/#/centaur-tabs][file:https://melpa.org/packages/centaur-tabs-badge.svg]]
[[http://www.gnu.org/licenses/gpl-3.0][file:https://img.shields.io/badge/License-GPL%20v3-blue.svg]]

  • Contents :TOC:
  • [[#what-is-this][What is this?]]
  • [[#installation][Installation]]
  • [[#customization][Customization]]
    • [[#headline-face][Headline face]]
    • [[#tab-styles][Tab Styles]]
    • [[#tab-height][Tab height]]
    • [[#tab-icons][Tab icons]]
    • [[#graying-out-icons][Graying out icons]]
    • [[#selected-tab-bar][Selected tab bar]]
    • [[#customize-the-close-button][Customize the close button]]
    • [[#customize-the-modified-marker][Customize the modified marker]]
    • [[#change-the-font-family-and-height][Change the font family and height]]
    • [[#disable-centaur-tabs-in-selected-buffers][Disable centaur-tabs in selected buffers]]
    • [[#buffer-groups][Buffer groups]]
    • [[#show-buffer-groups-names-instead-of-buffer-names-in-tabs][Show buffer groups names instead of buffer names in tabs]]
    • [[#enable-vim-like-tab-motions][Enable Vim like tab motions]]
    • [[#prevent-the-access-to-specified-buffers][Prevent the access to specified buffers]]
    • [[#tab-cycling][Tab cycling]]
    • [[#buffer-reordering][Buffer reordering]]
    • [[#helm-integration][Helm integration]]
    • [[#ivy-integration][Ivy integration]]
    • [[#projectile-integration][Projectile integration]]
    • [[#mouse-support][Mouse support]]
  • [[#to-do-1519][TO DO]]
  • [[#my-personal-configuration][My personal configuration]]
  • [[#known-supported-theme-plugins][Known supported theme plugins]]
  • [[#how-to-contribute][How to contribute]]
  • What is this?
    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 [[https://github.com/manateelazycat/awesome-tab][awesome-tab]] (that I forked with the permission from the author and it's also based on [[https://github.com/dholm/tabbar][tabbar]]) it's been heavily modified so now it may be considered a different package.
    Also this package integrates functionalities from [[https://github.com/mattfidler/tabbar-ruler.el][tabbar-ruler]].

    It currently looks like this (although there's a ton of possible configurations):

  • Installation
    You can download this package from MELPA. This is a basic ~use-package~ configuration:
    #+BEGIN_SRC emacs-lisp :tangle yes
    (use-package centaur-tabs
    :demand
    :config
    (centaur-tabs-mode t)
    :bind
    ("C-" . centaur-tabs-backward)
    ("C-" . centaur-tabs-forward))
    #+END_SRC

    Or if you use require:
    #+BEGIN_SRC emacs-lisp :tangle yes
    (require 'centaur-tabs)
    (centaur-tabs-mode t)
    (global-set-key (kbd "C-") 'centaur-tabs-backward)
    (global-set-key (kbd "C-") 'centaur-tabs-forward)
    #+END_SRC

  • Customization
    This package is heavily customizable, with many options available to the user. Here are some of them:
    ** Headline face
    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:
    #+BEGIN_SRC emacs-lisp :tangle yes
    (centaur-tabs-headline-match)
    #+END_SRC
    ** Tab Styles
    To change the tab style, modify the centaur-tabs-style variable like this:
    #+BEGIN_SRC emacs-lisp :tangle yes
    (setq centaur-tabs-style "bar")
    #+END_SRC

    The options available are:

    • "alternate"

    • "bar"

    • "box"

    • "chamfer"

    • "rounded"

    • "slant"

    • "wave"

    • "zigzag"

** Tab height
To change the tab height do
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-height 32)
#+END_SRC
** Tab icons
To display themed icons from all the icons
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-set-icons t)
#+END_SRC
** Graying out icons
To gray out icons for the unselected tabs:
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-gray-out-icons 'buffer)
#+END_SRC
*** TODO Implement functionality for unselected windows instead of unselected buffer.
** Selected tab bar
To display a colored bar at the left of the selected tab
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-set-bar 'left)
#+END_SRC

To display an overline over the selected tab:
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-set-bar 'over)
#+END_SRC

To display an underline over the selected tab:
#+BEGIN_SRC emacs-lisp :tangle yes
(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)
#+END_SRC

The color can be customized via the centaur-tabs-active-bar-face face.
** Customize the close button
To disable the close button
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-set-close-button nil)
#+END_SRC
To change the displayed string for the close button
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-close-button "X")
#+END_SRC
Also there are two faces to customize the close button string: centaur-tabs-close-unselected and centaur-tabs-close-selected
** Customize the modified marker
To display a marker indicating that a buffer has been modified (atom-style)
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-set-modified-marker t)
#+END_SRC
To change the displayed string for the modified-marker
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-modified-marker "*")
#+END_SRC
Also there are two faces to customize the close button string: centaur-tabs-modified-marker-unselected and centaur-tabs-modified-marker-selected

** Change the font family and height
To easily customize the tabs font by changing it's height and font family use the following function:
#+BEGIN_SRC emacs-lisp :tangle yes
(centaur-tabs-change-fonts "arial" 160)
#+END_SRC
** Disable centaur-tabs in selected buffers
To disable the tabs in a buffer just add a hook to the ~centaur-tabs-local-mode~ function like this:
#+BEGIN_SRC emacs-lisp :tangle yes
(add-hook 'dired-mode-hook 'centaur-tabs-local-mode)
#+END_SRC

or with ~use-package~:
#+BEGIN_SRC emacs-lisp :tangle yes
(use-package centaur-tabs
...
:hook
(dired-mode . centaur-tabs-local-mode)
...)
#+END_SRC

** Buffer groups
To customize the way that the buffers are grouped modify the ~centaur-tabs-buffer-groups~ function like this:
#+BEGIN_SRC emacs-lisp :tangle yes
(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))))))

#+END_SRC

** Show buffer groups names instead of buffer names in tabs
If you want your tabs to display buffer groups names instead of buffer names you can put the following in your configuration:
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs--buffer-show-groups t)
#+END_SRC
You can toggle between the two options interactively with the ~(centaur-tabs-toggle-groups)~ command.
** Enable Vim like tab motions
To enable Vim like tab changing binds
#+BEGIN_SRC emacs-lisp :tangle yes
(define-key evil-normal-state-map (kbd "g t") 'centaur-tabs-forward)
(define-key evil-normal-state-map (kbd "g T") 'centaur-tabs-backward)
#+END_SRC

or with ~use-package~:
#+BEGIN_SRC emacs-lisp :tangle yes
(use-package centaur-tabs
...
:bind
(:map evil-normal-state-map
("g t" . centaur-tabs-forward)
("g T" . centaur-tabs-backward))
...)
#+END_SRC
** Prevent the access to specified buffers
You can prevent the access to some buffers via tab motions changing the following function like this:
#+BEGIN_SRC emacs-lisp :tangle yes
(defun centaur-tabs-hide-tab (x)
(let ((name (format "%s" x)))
(or
(string-prefix-p "*epc" name)
(string-prefix-p "*helm" name)
(string-prefix-p "Compile-Log" name)
(string-prefix-p "*lsp" name)
(and (string-prefix-p "magit" name)
(not (file-name-extension name)))
)))
#+END_SRC
** Tab cycling
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:
#+BEGIN_SRC emacs-lisp :tangle yes
(setq centaur-tabs-cycle-scope 'tabs)
#+END_SRC

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
    ** Buffer reordering
    To enable an automatic buffer reordering function use the following function in your configuration:
    #+BEGIN_SRC emacs-lisp :tangle yes
    (centaur-tabs-enable-buffer-reordering)
    #+END_SRC
    #+BEGIN_SRC emacs-lisp :tangle yes
    ;; 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)
    #+END_SRC

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~.
** Helm integration
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).
** Ivy integration
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.
** Projectile integration
You can group your tabs by Projectile's project. Just use the following function in your configuration:
#+BEGIN_SRC emacs-lisp :tangle yes
(centaur-tabs-group-by-projectile-project)
#+END_SRC

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:
#+BEGIN_SRC emacs-lisp :tangle yes
(centaur-tabs-group-buffer-groups)
#+END_SRC
** Mouse support

  • Just click in a tab to change the buffer of the current window.
  • Click the mouse wheel to close a buffer.
  • Right click on any part of the header line (tabs or empty space) to show a tab groups popup.
  • Use the mouse wheel to invoke ~centaur-tabs-backward/forward~.
  • Set the =centaur-tabs-show-navigation-buttons= customizable variable to =t= to display cool navigation buttons.
  • TO DO [15/19]

    • Integrate all-the-icons
    • Improve all the icons placing
    • Fix all the icons background
    • Add selected, unselected, selected-modified and unselected-modified faces
    • Make function to inherit tabbar faces
    • Group tabs by projectile's project (was already implemented but not for projectile)
    • Create PR to different theme packages for this package
    • Add modified marker icon option
    • Add sideline for selected tab (atom style)
    • 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")~)
    • Make icon insert after the separator
    • Add a customizable close button
    • Explore if ~after-modifying-buffer~ function can be improved
    • Fix messages buffer icon an FontAwesome errors
    • Check for Elscreen compatibility
    • Add this package to MELPA
    • 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
    My personal configuration for reference:

#+BEGIN_SRC emacs-lisp :tangle yes
(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-" . centaur-tabs-backward)
("C-" . 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)))
#+END_SRC

  • Known supported theme plugins
    • [[https://github.com/jonathanchu/atom-one-dark-theme][Atom One Dark Theme]]
    • [[https://github.com/belak/base16-emacs][Base16]]
    • [[https://github.com/SavchenkoValeriy/emacs-chocolate-theme][Chocolate Theme]]
    • [[https://github.com/hlissner/emacs-doom-themes][Doom Themes]]
    • [[https://github.com/ogdenwebb/emacs-kaolin-themes][Kaolin Themes]]
    • [[https://github.com/nashamri/spacemacs-theme][Spacemacs Theme]]
    • [[https://github.com/ianpan870102/tron-legacy-emacs-theme][Tron Legacy]]
    • [[https://github.com/ianpan870102/wilmersdorf-emacs-theme][Wilmersdorf Theme]]
    • [[https://github.com/bbatsov/zenburn-emacs][Zenburn]]
  • How to contribute
    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.

Main metrics

Overview
Name With Ownerema2159/centaur-tabs
Primary LanguageEmacs Lisp
Program languageEmacs Lisp (Language Count: 2)
Platform
License:GNU General Public License v3.0
所有者活动
Created At2019-06-20 01:17:28
Pushed At2025-04-23 00:27:14
Last Commit At2025-04-22 17:27:14
Release Count4
Last Release Name3.2 (Posted on )
First Release Namev3.0 (Posted on )
用户参与
Stargazers Count783
Watchers Count8
Fork Count53
Commits Count512
Has Issues Enabled
Issues Count202
Issue Open Count73
Pull Requests Count51
Pull Requests Open Count3
Pull Requests Close Count3
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private