Skip to content

Instantly share code, notes, and snippets.

@3demax
Created October 5, 2011 14:58
Show Gist options
  • Save 3demax/1264635 to your computer and use it in GitHub Desktop.
Save 3demax/1264635 to your computer and use it in GitHub Desktop.
Emacs tabbar-mode visual tweaks
;; This are setting for nice tabbar items
;; to have an idea of what it looks like http://imgur.com/b0SNN
;; inspired by Amit Patel screenshot http://www.emacswiki.org/pics/static/NyanModeWithCustomBackground.png
;; Tabbar
(require 'tabbar)
;; Tabbar settings
(set-face-attribute
'tabbar-default nil
:background "gray20"
:foreground "gray20"
:box '(:line-width 1 :color "gray20" :style nil))
(set-face-attribute
'tabbar-unselected nil
:background "gray30"
:foreground "white"
:box '(:line-width 5 :color "gray30" :style nil))
(set-face-attribute
'tabbar-selected nil
:background "gray75"
:foreground "black"
:box '(:line-width 5 :color "gray75" :style nil))
(set-face-attribute
'tabbar-highlight nil
:background "white"
:foreground "black"
:underline nil
:box '(:line-width 5 :color "white" :style nil))
(set-face-attribute
'tabbar-button nil
:box '(:line-width 1 :color "gray20" :style nil))
(set-face-attribute
'tabbar-separator nil
:background "gray20"
:height 0.6)
;; Change padding of the tabs
;; we also need to set separator to avoid overlapping tabs by highlighted tabs
(custom-set-variables
'(tabbar-separator (quote (0.5))))
;; adding spaces
(defun tabbar-buffer-tab-label (tab)
"Return a label for TAB.
That is, a string used to represent it on the tab bar."
(let ((label (if tabbar--buffer-show-groups
(format "[%s] " (tabbar-tab-tabset tab))
(format "%s " (tabbar-tab-value tab)))))
;; Unless the tab bar auto scrolls to keep the selected tab
;; visible, shorten the tab label to keep as many tabs as possible
;; in the visible area of the tab bar.
(if tabbar-auto-scroll-flag
label
(tabbar-shorten
label (max 1 (/ (window-width)
(length (tabbar-view
(tabbar-current-tabset)))))))))
(tabbar-mode 1)
Copy link

ghost commented Mar 3, 2013

Thanks for the tabbar-buffer-tab-label!

@wh1tew0lf
Copy link

It is really cool!

Copy link

ghost commented Jan 9, 2014

How can I resize height of the tabbar? :(

@huyz
Copy link

huyz commented Aug 23, 2014

@darvein Resize height of the tabbar this way:

(set-face-attribute
 'tabbar-default nil
 :background "gray20"
 :foreground "gray20"
 :box '(:line-width 1 :color "gray20" :style nil)
 :height 1.3)

@banyudu
Copy link

banyudu commented Jan 28, 2016

error: Invalid face, tabbar-default with emacsw64

@banyudu
Copy link

banyudu commented Jan 28, 2016

move (tabbar-mode 1) to before set-face-attribute fixes the 'invalid face' error.

@xpopy
Copy link

xpopy commented Apr 19, 2016

How would I enable this for the tabbar-ruler package?

@jglev
Copy link

jglev commented Jul 11, 2017

Thanks very much for this! Is there a license that you've assigned to this? I'd like to incorporate it into a GPLv3-licensed project I'm working on, and so would like to check with you about your expectations for this gist.

@yozhsh
Copy link

yozhsh commented Oct 9, 2018

Thank you very much!

@tavoaqp-zz
Copy link

thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment