-
-
Save creichert/1e8f4248116ee93077f54ac0d28dfd6a to your computer and use it in GitHub Desktop.
my emacs mode line config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun mode-line-fill-right (face reserve) | |
"Return empty space using FACE and leaving RESERVE space on the right." | |
(unless reserve | |
(setq reserve 20)) | |
(when (and window-system (eq 'right (get-scroll-bar-mode))) | |
(setq reserve (- reserve 3))) | |
(propertize " " | |
'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve))) | |
'face face)) | |
(defun mode-line-fill-center (face reserve) | |
"Return empty space using FACE to the center of remaining space leaving RESERVE space on the right." | |
(unless reserve | |
(setq reserve 20)) | |
(when (and window-system (eq 'right (get-scroll-bar-mode))) | |
(setq reserve (- reserve 3))) | |
(propertize " " | |
'display `((space :align-to (- (+ center (.5 . right-margin)) ,reserve | |
(.5 . left-margin)))) | |
'face face)) | |
(defconst RIGHT_PADDING 1) | |
(defun reserve-left/middle () | |
(/ (length (format-mode-line mode-line-align-middle)) 2)) | |
(defun reserve-middle/right () | |
(+ RIGHT_PADDING (length (format-mode-line mode-line-align-right)))) | |
(setq mode-line-align-left | |
'("" | |
"%2 " | |
(:eval (format "%s" exwm-workspace-current-index)) | |
"%2 " | |
(:eval | |
(cond | |
((string= major-mode "emacs-lisp-mode") "") | |
((string= major-mode "lisp-mode") "") | |
((string= major-mode "dired-mode") "") | |
((string= major-mode "elixir-mode") (propertize " " 'face '(:family "all-the-icons"))) | |
((string= major-mode "text-mode") (propertize "" 'face '(:family "file-icons"))) | |
((string= major-mode "org-mode") "") | |
;; ((string= major-mode "erc-mode") "") | |
((string= major-mode "erc-mode") (propertize "" 'face '(:family "icomoon"))) | |
((string= major-mode "eshell-mode") (propertize "" 'face '(:family "all-the-icons"))) | |
((string= major-mode "sh-mode") (propertize "" 'face '(:family "all-the-icons"))) | |
((string= major-mode "js2-mode") "") | |
((string= major-mode "js-mode") "") | |
((string= major-mode "typescript-mode") "") | |
((string= major-mode "exwm-mode") "") | |
((string= major-mode "vue-mode") "") | |
((string= major-mode "html-mode") "") | |
((string= major-mode "css-mode") "") | |
((string= major-mode "java-mode") "") | |
((string= major-mode "xml-mode") (propertize "" 'face '(:family "all-the-icons"))) | |
((string= major-mode "erlang-mode") "") | |
((string= major-mode "python-mode") "") | |
((string= major-mode "ruby-mode") "") | |
((string= major-mode "c++-mode") (propertize "" 'face '(:family "font-mfizz"))) | |
((string= major-mode "scss-mode") (propertize "" 'face '(:family "all-the-icons"))) | |
((string= major-mode "php-mode") ) | |
((string= major-mode "go-mode") (propertize "" 'face '(:family "font-mfizz"))) | |
((string= major-mode "haskell-mode") "") | |
((string= major-mode "scale-mode") "") | |
((string= major-mode "lua-mode") "") | |
((string= major-mode "clojure-mode") "") | |
((string= major-mode "c-mode") "") | |
((string= major-mode "rust-mode") (propertize "" 'face '(:family "font-mfizz"))) | |
(t (format "%s" major-mode)))) | |
"%2 " | |
(:propertize "%b" face mode-line-buffer-id) | |
"%2 " | |
(:eval (when (bound-and-true-p flycheck-mode) (flycheck-mode-line-status-text))) | |
" ")) | |
(setq mode-line-align-middle | |
'("" | |
(vc-mode vc-mode) | |
"%3 " | |
;; (:propertize "%b" face mode-line-buffer-id) | |
(:eval | |
(when (eql (buffer-modified-p) t) | |
;; propertize adds metadata to text, so you can add colours and formatting, amongst other things | |
(propertize "" 'face '(:foreground "white")))) | |
" " | |
(:eval | |
(when (eql buffer-read-only t) | |
(propertize "" 'face '(:foreground "pink")))) | |
"")) | |
(setq mode-line-align-right | |
'("" | |
mode-line-misc-info | |
"%2 " | |
(:eval (format "%%l/%d : %%c " (line-number-at-pos (point-max)))))) | |
(setq-default mode-line-format | |
(list | |
mode-line-align-left | |
'(:eval (mode-line-fill-center 'mode-line | |
(reserve-left/middle))) | |
mode-line-align-middle | |
'(:eval | |
(mode-line-fill-right 'mode-line | |
(reserve-middle/right))) | |
mode-line-align-right)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment