;; Taken from http://amitp.blogspot.com/2011/08/emacs-custom-mode-line.html ;; Mode line setup (setq-default mode-line-format '(; Position, including warning for 80 columns (:propertize "%3l:" face mode-line-position-face) (:eval (propertize "%3c" 'face (if (>= (current-column) 80) (if (>= (current-column) 100) 'mode-line-100col-face 'mode-line-80col-face) 'mode-line-position-face))) ; emacsclient [default -- keep?] mode-line-client " " ; read-only or modified status (:eval (cond (buffer-read-only (propertize " RO " 'face 'mode-line-read-only-face)) ((buffer-modified-p) (propertize " ** " 'face 'mode-line-modified-face)) (t " "))) " " ; directory and buffer/file name (:propertize (:eval (shorten-directory default-directory 30)) face mode-line-folder-face) (:propertize "%b" face mode-line-filename-face) ; narrow [default -- keep?] " %n " ; mode indicators: vc, recursive edit, major mode, minor modes, process, global (vc-mode vc-mode) " %[" (:propertize mode-name face mode-line-mode-face) "%] " (:eval (propertize (format-mode-line minor-mode-alist) 'face 'mode-line-face)) (:propertize mode-line-process face mode-line-process-face) (global-mode-string global-mode-string) " " )) ;; Helper function (defun shorten-directory (dir max-length) "Show up to `max-length' characters of a directory name `dir'." (let ((path (reverse (split-string (abbreviate-file-name dir) "/"))) (output "")) (when (and path (equal "" (car path))) (setq path (cdr path))) (while (and path (< (length output) (- max-length 4))) (setq output (concat (car path) "/" output)) (setq path (cdr path))) (when path (setq output (concat ".../" output))) output)) ;; Extra mode line faces (make-face 'mode-line-read-only-face) (make-face 'mode-line-modified-face) (make-face 'mode-line-folder-face) (make-face 'mode-line-filename-face) (make-face 'mode-line-position-face) (make-face 'mode-line-mode-face) (make-face 'mode-line-process-face) (make-face 'mode-line-80col-face) (make-face 'mode-line-100col-face) (set-face-attribute 'mode-line-read-only-face nil :inherit 'mode-line-face :foreground "#4271ae") (set-face-attribute 'mode-line-modified-face nil :inherit 'mode-line-face :foreground "#c82829") (set-face-attribute 'mode-line-folder-face nil :inherit 'mode-line-face :foreground "gray90") (set-face-attribute 'mode-line-filename-face nil :inherit 'mode-line-face :foreground "grey70" :weight 'bold) (set-face-attribute 'mode-line-position-face nil :inherit 'mode-line-face :family "Roboto mono" :foreground "grey70" :weight 'bold :height 100) (set-face-attribute 'mode-line-mode-face nil :inherit 'mode-line-face :foreground "gray100") (set-face-attribute 'mode-line-process-face nil :inherit 'mode-line-face :foreground "#718c00") (set-face-attribute 'mode-line-80col-face nil :inherit 'mode-line-position-face :foreground "white" :background "#eab700") (set-face-attribute 'mode-line-100col-face nil :inherit 'mode-line-position-face :foreground "white" :background "red")