init-shell.el 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ;;; init-shell.el --- eshell/vterm Configuration File -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;;; Code:
  4. (use-feature eshell
  5. :bind ("C-x m " . eshell)
  6. :hook
  7. (eshell-pre-command . eshell-save-some-history)
  8. (eshell-mode-hook . (lambda () (setenv "TERM" "xterm-256color")))
  9. :custom
  10. (eshell-directory-name (expand-file-name "eshell" save-dir))
  11. ;; https://lambdaland.org/posts/2024-08-19_fancy_eshell_prompt/#eshell-prompt
  12. (eshell-highlight-prompt nil)
  13. (eshell-prompt-regexp "^[^#$\n]* [$#] ")
  14. (eshell-prompt-function
  15. (lambda ()
  16. (let* ((cwd (abbreviate-file-name (eshell/pwd)))
  17. (ref (magit-get-shortname "HEAD"))
  18. (stat (magit-file-status))
  19. (x-stat eshell-last-command-status)
  20. (git-chunk
  21. (if ref
  22. (format "%s%s%s "
  23. (propertize (if stat "[" "(") 'font-lock-face (list :foreground (if stat "red" "green")))
  24. (propertize ref 'font-lock-face '(:foreground "yellow"))
  25. (propertize (if stat "]" ")") 'font-lock-face (list :foreground (if stat "red" "green"))))
  26. "")))
  27. (propertize
  28. (format "%s %s %s$ "
  29. (if (< 0 x-stat) (format (propertize "!%s" 'font-lock-face '(:foreground "red")) x-stat)
  30. (propertize "➤" 'font-lock-face (list :foreground (if (< 0 x-stat) "red" "green"))))
  31. (propertize cwd 'font-lock-face '(:foreground "#45babf"))
  32. git-chunk)
  33. 'read-only t
  34. 'front-sticky '(font-lock-face read-only)
  35. 'rear-nonsticky '(font-lock-face read-only)))))
  36. :config
  37. (setenv "PAGER" "cat"))
  38. (use-package eshell-z
  39. :hook (eshell-mode . (lambda () (require 'eshell-z))))
  40. (use-package eshell-syntax-highlighting
  41. :after esh-mode
  42. :config
  43. (eshell-syntax-highlighting-global-mode +1))
  44. (use-package xterm-color
  45. :after esh-mode
  46. :hook
  47. (eshell-before-prompt . (lambda ()
  48. (setq xterm-color-preserve-properties t)))
  49. :config
  50. (push 'xterm-color-filter eshell-preoutput-filter-functions)
  51. (delq 'eshell-handle-ansi-color eshell-output-filter-functions)
  52. (setenv "TERM" "xterm-256color"))
  53. ;; Installed with home-manager
  54. (use-feature multi-vterm
  55. :bind (("C-c t" . multi-vterm-next)
  56. ("C-x p t" . multi-vterm-project)
  57. ("C-c C-M-t" . multi-vterm)
  58. (:map vterm-mode-map
  59. ("M-[" . multi-vterm-prev)
  60. ("M-]" . multi-vterm-next))))
  61. (provide 'init-shell)
  62. ;;; init-shell.el ends here