module-eshell.el (1892B)
1 ;;; module-eshell.el 2 3 ;; Author: Mark Feller <mark.feller@member.fsf.org> 4 5 ;; This file is not part of GNU Emacs. 6 7 ;; This file is free software; you can redistribute it and/or modify 8 ;; it under the terms of the GNU General Public License as published by 9 ;; the Free Software Foundation; either version 3, or (at your option) 10 ;; any later version. 11 12 ;; This file is distributed in the hope that it will be useful, 13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ;; GNU General Public License for more details. 16 17 ;; You should have received a copy of the GNU General Public License 18 ;; along with this file. If not, see <http://www.gnu.org/licenses/>. 19 20 ;;; Commentary: 21 22 ;;; Code: 23 24 (defun mjf/set-exec-path-from-shell-PATH () 25 "Set up Emacs' `exec-path` and PATH environment variable to 26 match that used by the user's shell. This is particularly 27 useful under macOS, where GUI apps are not started from a 28 shell." 29 (interactive) 30 (let ((path-from-shell 31 (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'")))) 32 (setenv "PATH" path-from-shell) 33 (setq exec-path (split-string path-from-shell path-separator)))) 34 35 (use-package eshell 36 :bind 37 (:map eshell-mode-map 38 ("C-l". evil-scroll-line-to-top)) 39 40 :config 41 (setq eshell-directory-name "~/.cache/eshell" 42 eshell-cmpl-cycle-completions nil 43 eshell-buffer-maximum-lines 20000 44 eshell-history-size 350 45 eshell-buffer-shorthand t ; buffer shorthand -> echo foo > #'buffer 46 eshell-highlight-prompt nil 47 eshell-plain-echo-behavior t) ; treat 'echo' like shell echo 48 49 (add-hook 'eshell-mode-hook 'disable-line-numbers) 50 (add-to-list 'eshell-load-hook 'mjf/set-exec-path-from-shell-PATH)) 51 52 (provide 'module-eshell) 53 54 ;;; module-eshell.el ends here