dkellner-eshell.el 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ;; dkellner-eshell.el --- Eshell configuration
  2. (add-hook 'eshell-first-time-mode-hook #'dkellner/setup-eshell)
  3. (add-hook 'eshell-mode-hook #'dkellner/add-eshell-keys)
  4. (setq eshell-history-size 10000)
  5. (defun dkellner/setup-eshell ()
  6. (setq eshell-visual-commands
  7. '("ssh" "mutt-puzzleandplay" "mutt-dkellner" "mplayer" "mysql" "vi"
  8. "screen" "top" "less" "more"))
  9. (setq eshell-visual-subcommands
  10. '(("nixops" "ssh")
  11. ("nix" "repl")
  12. ("docker" "exec")))
  13. (setq eshell-visual-options
  14. '(("gcloud" "connect" "ssh")
  15. ("kubectl" "exec")))
  16. (setq eshell-where-to-jump 'begin
  17. eshell-review-quick-commands nil
  18. eshell-smart-space-goes-to-end t
  19. eshell-prompt-regexp "^.* λ "
  20. eshell-prompt-function #'dkellner/eshell-prompt))
  21. ;; see https://gitlab.com/bennya/shrink-path.el
  22. (defun dkellner/eshell-prompt ()
  23. (let ((base-dir (shrink-path-prompt default-directory)))
  24. (concat (propertize (car base-dir)
  25. 'face 'font-lock-comment-face)
  26. (propertize (cdr base-dir)
  27. 'face 'font-lock-constant-face)
  28. (propertize " λ" 'face 'eshell-prompt-face)
  29. ;; needed for the input text to not have prompt face
  30. (propertize " " 'face 'default))))
  31. (defun dkellner/add-eshell-keys ()
  32. (define-key eshell-mode-map (kbd "C-c C-l") #'counsel-esh-history)
  33. (define-key eshell-mode-map (kbd "C-x k") #'kill-buffer-and-window)
  34. (define-key eshell-mode-map (kbd "<up>") #'previous-line)
  35. (define-key eshell-mode-map (kbd "<down>") #'next-line))
  36. (defun dkellner/new-eshell ()
  37. "Open a new Eshell.
  38. The shell is opened in the directory associated with the current
  39. buffer's file. The eshell buffer is renamed to match that
  40. directory."
  41. (interactive)
  42. (let* ((dir (if (buffer-file-name)
  43. (file-name-directory (buffer-file-name))
  44. default-directory))
  45. (name (abbreviate-file-name dir)))
  46. (eshell t)
  47. (rename-buffer (concat "*eshell:" name "*"))))
  48. (provide 'dkellner-eshell)