UP | HOME

A minimal but useful mode-line

I've been using doom-modeline for a while, it was great but I still want it more simpler. So I rolled my own mode-line.

VQZDsBE.png

It only has a few things: editing status, an icon of the current mode, a file path, current line, and the current git branch.

Here's the script:

;; Auto updating version control information
(setq auto-revert-check-vc-info t)
(setq-default mode-line-format (list
  ;; Check the buffer status and display its status
  ;; ⚿ for locked buffer. ⛯ for modified buffer. ⛆ is the normal one.
  '((:eval
     (cond
      (buffer-read-only
       (propertize " ⚿ " 'face '(:foreground "red" :weight 'bold)))
      ((buffer-modified-p)
       (propertize " ⛯ " 'face '(:foreground "orange")))
      ((not (buffer-modified-p))
       (propertize " ⛆ " 'face '(:foreground "gray85"))))))
  ;; Use all-the-icons to display the icon of current major mode
  '(:eval (propertize (all-the-icons-icon-for-mode major-mode
          :height (/ all-the-icons-scale-factor 1.4)
          :v-adjust -0.03)))
  ;; Show the file name with full path
  " %f "
  ;; Show the current position of the cursor in buffer
  'mode-line-position
  ;; Show the current major mode name
  "[" 'mode-name "] "
  ;; Check if the buffer is in any version control system, if yes, show the branch
  '(:eval
    (if vc-mode
        (let* ((noback (replace-regexp-in-string
                           (format "^ %s" (vc-backend buffer-file-name)) " " vc-mode))
               (face (cond ((string-match "^ -" noback) 'mode-line-vc)
                           ((string-match "^ [:@]" noback) 'mode-line-vc-edit)
                           ((string-match "^ [!\\?]" noback) 'mode-line-vc-modified))))
          (format "[git:%s]" (substring noback 2)))))))

Date: 2019-04-17 Wed 00:00

Author: Huy Tran

Created: 2019-04-22 Mon 14:41