因为种种原因没有使用 spaceline,但是 mode-line 默认的样式实在是不好看,尤其是窗口太小时显示不全,自己美化了下 mode-line,先放效果图
(setq evil-normal-state-tag (propertize "[Normal]" 'face '((:background "green" :foreground "black")))
evil-emacs-state-tag (propertize "[Emacs]" 'face '((:background "orange" :foreground "black")))
evil-insert-state-tag (propertize "[Insert]" 'face '((:background "red") :foreground "white"))
evil-motion-state-tag (propertize "[Motion]" 'face '((:background "blue") :foreground "white"))
evil-visual-state-tag (propertize "[Visual]" 'face '((:background "grey80" :foreground "black")))
evil-operator-state-tag (propertize "[Operator]" 'face '((:background "purple"))))
;; 简化 major-mode 的名字,替换表中没有的显示原名
(defun codefalling//simplify-major-mode-name ()
"Return simplifyed major mode name"
(let* ((major-name (format-mode-line "%m"))
(replace-table '(Emacs-Lisp "𝝀"
Spacemacs\ buffer "𝓢"
Python "𝝅"
Shell ">"
Makrdown "𝓜"
GFM "𝓜"
Org "𝒪"
Text "𝓣"
Fundamental "ℱ"
))
(replace-name (plist-get replace-table (intern major-name))))
(if replace-name replace-name major-name
)))
(setq-default
mode-line-format
(list
;; the buffer name; the file name as a tool tip
" "
'(:eval (propertize "%b " 'face 'font-lock-keyword-face
'help-echo (buffer-file-name)))
;; line and column
"(" ;; '%02' to set to 2 chars at least; prevents flickering
(propertize "%02l" 'face 'font-lock-type-face) ","
(propertize "%02c" 'face 'font-lock-type-face)
") "
;; relative position, size of file
"["
(propertize "%p" 'face 'font-lock-constant-face) ;; % above top
"/"
(propertize "%I" 'face 'font-lock-constant-face) ;; size
"] "
;; the current major mode for the buffer.
"["
'(:eval (propertize (codefalling//simplify-major-mode-name) 'face 'font-lock-string-face
'help-echo buffer-file-coding-system))
"] "
"[" ;; insert vs overwrite mode, input-method in a tooltip
'(:eval (propertize (if overwrite-mode "Ovr" "Ins")
'face 'font-lock-preprocessor-face
'help-echo (concat "Buffer is in "
(if overwrite-mode "overwrite" "insert") " mode")))
;; was this buffer modified since the last save?
'(:eval (when (buffer-modified-p)
(concat "," (propertize "Mod"
'face 'font-lock-warning-face
'help-echo "Buffer has been modified"))))
;; is this buffer read-only?
'(:eval (when buffer-read-only
(concat "," (propertize "RO"
'face 'font-lock-type-face
'help-echo "Buffer is read-only"))))
"] "
;; evil state
'(:eval (evil-generate-mode-line-tag evil-state))
" "
;; add the time, with the date and the emacs uptime in the tooltip
'(:eval (propertize (format-time-string "%H:%M")
'help-echo
(concat (format-time-string "%c; ")
(emacs-uptime "Uptime:%hh"))))
" --"
;; i don't want to see minor-modes; but if you want, uncomment this:
;; minor-mode-alist ;; list of minor modes
"%-" ;; fill with '-'
))
有什么问题或者要补充的可以去 Mode line · CodeFalling/wiki Wiki