blob: 4c81830faa8c364dd191b54034269bf080946f4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
;; Inherit the face of `doom-modeline-panel` for better appearance
(set-face-attribute 'tab-bar-tab nil :inherit 'doom-modeline-panel :foreground nil :background nil)
;; Totally customize the format of the tab bar name
(defun my/tab-bar-format (tab i)
(propertize
(format
(concat
(if (eq (car tab) 'current-tab)
"🔥 " "")
"%s")
(alist-get 'name tab))
'face (list (append
'(:foreground "#FFFFFF")
(if (eq (car tab) 'current-tab)
'(:box t)
'())))))
(global-set-key (kbd "C-<next>") 'tab-bar-switch-to-next-tab)
(global-set-key (kbd "C-<prior>") 'tab-bar-switch-to-prev-tab)
;; Replace the default tab bar function
(setq tab-bar-tab-name-format-function #'my/tab-bar-format)
(defun my/tab-bar-tab-name-function ()
"Return project name if in a project, or default tab-bar name if not.
The default tab-bar name uses the buffer name."
(let ((project-name (projectile-project-name)))
(if (string= "-" project-name)
(tab-bar-tab-name-current)
(projectile-project-name))))
(setq tab-bar-tab-name-function #'my/tab-bar-tab-name-function)
;; Only show the tab bar if there are 2 or more tabs
(setq tab-bar-show 1)
;; Customize the tab bar format to add the global mode line string
(setq tab-bar-format '(tab-bar-format-tabs tab-bar-separator tab-bar-format-align-right tab-bar-format-global))
;; Make sure mode line text in the tab bar can be read
(set-face-attribute 'tab-bar nil :foreground "#FFFFFF")
(defun my/project-create-tab ()
(interactive)
(tab-bar-new-tab)
(magit-status))
(setq project-switch-commands #'my/project-create-tab)
(defun my/switch-to-tab-buffer ()
(interactive)
(if (project-current)
(call-interactively #'projectile-switch-to-buffer)
(call-interactively #'switch-to-buffer)))
(global-set-key (kbd "C-x b") #'my/switch-to-tab-buffer)
;; Turn on tab bar mode after startup
(tab-bar-mode 1)
;; Save the desktop session
(desktop-save-mode 1)
(setq tab-bar-new-tab-choice "*dashboard*")
|