2013-07-21 01:23:03 +02:00
|
|
|
;; EShell configuration
|
|
|
|
|
2013-07-21 01:49:53 +02:00
|
|
|
(require 'eshell)
|
|
|
|
|
2013-07-29 18:44:02 +02:00
|
|
|
;; Generic settings
|
|
|
|
;; Hide banner message ...
|
|
|
|
(setq eshell-banner-message "")
|
|
|
|
|
2013-07-21 01:23:03 +02:00
|
|
|
(defvar home-dir)
|
|
|
|
(setq home-dir (expand-file-name "~"))
|
|
|
|
|
2013-07-22 11:43:48 +02:00
|
|
|
(defun eshell-mode-hook-setup ()
|
|
|
|
"Sets up EShell when it is loaded"
|
|
|
|
(setq eshell-path-env (concat
|
|
|
|
"/usr/local/bin:"
|
|
|
|
(concat home-dir "/bin:")
|
2013-07-30 16:19:58 +02:00
|
|
|
"/usr/local/share/python:"
|
2013-07-22 11:43:48 +02:00
|
|
|
eshell-path-env))
|
|
|
|
|
|
|
|
(setenv "PATH" eshell-path-env))
|
|
|
|
|
|
|
|
(add-hook 'eshell-mode-hook 'eshell-mode-hook-setup)
|
2013-07-21 01:23:03 +02:00
|
|
|
|
|
|
|
;; Prompt configuration
|
|
|
|
|
|
|
|
(defun clean-pwd (path)
|
|
|
|
"Turns a path of the form /foo/bar/baz into /f/b/baz
|
|
|
|
(inspired by fish shell)"
|
2013-08-17 20:43:05 +02:00
|
|
|
(let* ((hpath (replace-regexp-in-string home-dir
|
|
|
|
"~"
|
|
|
|
path))
|
|
|
|
(current-dir (split-string hpath "/"))
|
2013-07-21 01:23:03 +02:00
|
|
|
(cdir (last current-dir))
|
|
|
|
(head (butlast current-dir)))
|
|
|
|
(concat (mapconcat (lambda (s)
|
|
|
|
(if (string= "" s) nil
|
|
|
|
(substring s 0 1)))
|
|
|
|
head
|
|
|
|
"/")
|
|
|
|
(if head "/" nil)
|
|
|
|
(car cdir))))
|
|
|
|
|
|
|
|
(defun vcprompt (&optional args)
|
|
|
|
"Call the external vcprompt command with optional arguments.
|
|
|
|
VCPrompt"
|
|
|
|
(replace-regexp-in-string
|
|
|
|
"\n" ""
|
|
|
|
(shell-command-to-string (concat "vcprompt" args))))
|
|
|
|
|
|
|
|
(defmacro with-face (str &rest properties)
|
|
|
|
`(propertize ,str 'face (list ,@properties)))
|
|
|
|
|
|
|
|
(defun prompt-f ()
|
|
|
|
"My EShell prompt displaying VC info and such"
|
|
|
|
(concat
|
2013-08-17 20:43:05 +02:00
|
|
|
(with-face (concat (clean-pwd (eshell/pwd)) " ") :foreground "#96a6c8")
|
2013-07-21 01:23:03 +02:00
|
|
|
(with-face (vcprompt " -f \"(%s:%b%a%m) \"") :foreground "#5f627f")
|
|
|
|
(if (= 0 (user-uid))
|
|
|
|
(with-face "#" :foreground "#f43841")
|
|
|
|
(with-face "$" :foreground "#73c936"))
|
|
|
|
(with-face " " :foreground "#95a99f")))
|
|
|
|
|
|
|
|
|
|
|
|
(setq eshell-prompt-function 'prompt-f)
|
|
|
|
(setq eshell-highlight-prompt nil)
|
2013-07-22 02:26:51 +02:00
|
|
|
(setq eshell-prompt-regexp "^.+? \\((\\(git\\|svn\\|hg\\|darcs\\|cvs\\|bzr\\):.+?) \\)?[$#] ")
|
|
|
|
|
2013-07-28 18:02:36 +02:00
|
|
|
;; Ignore version control folders in autocompletion
|
|
|
|
(setq eshell-cmpl-cycle-completions nil
|
|
|
|
eshell-save-history-on-exit t
|
|
|
|
eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\)/\\'")
|
|
|
|
|
|
|
|
;; Load some EShell extensions
|
|
|
|
(eval-after-load 'esh-opt
|
|
|
|
'(progn
|
|
|
|
(require 'em-term)
|
|
|
|
(require 'em-cmpl)
|
|
|
|
;; More visual commands!
|
|
|
|
(add-to-list 'eshell-visual-commands "ssh")
|
2013-07-29 18:44:02 +02:00
|
|
|
(add-to-list 'eshell-visual-commands "tail")
|
|
|
|
(add-to-list 'eshell-visual-commands "sl")))
|
2013-07-28 18:02:36 +02:00
|
|
|
|
|
|
|
(setq eshell-directory-name "~/.config/eshell/")
|
2013-07-21 01:23:03 +02:00
|
|
|
|
|
|
|
;; EShell functions that come in handy
|
|
|
|
|
|
|
|
;; clear in eshell
|
|
|
|
(defun eshell/clear ()
|
|
|
|
"clear the eshell buffer."
|
|
|
|
(interactive)
|
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(erase-buffer)))
|
2013-08-07 00:49:20 +02:00
|
|
|
|
|
|
|
(provide 'init-eshell)
|