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.


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.
       (propertize " ⚿ " 'face '(:foreground "red" :weight 'bold)))
       (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
  ;; Show the current major mode name
  "[" 'mode-name "] "
  ;; Check if the buffer is in any version control system, if yes, show the branch
    (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)))))))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: