From 13b91519fe2e639cb8fea572cf6df597e838023b Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 29 Dec 2013 23:36:16 +0100 Subject: Use buffer-name for some information in eshell This makes the eshell prompt shorter --- .emacs.d/init.el | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to '.emacs.d/init.el') diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 6ac9ea5..38cffa4 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -359,28 +359,13 @@ For `python-mode' I prefer `python-imenu-create-flat-index'." (defun oni-eshell-prompt () "Show a pretty shell prompt." - (let ((status (if (zerop eshell-last-command-status) ?+ ?-)) - (hostname (hostname)) - (dir (abbreviate-file-name (eshell/pwd))) - (branch - (shell-command-to-string - "git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))) + (let ((status (if (zerop eshell-last-command-status) ?+ ?-))) (concat (propertize (char-to-string status) 'face `(:foreground ,(if (= status ?+) "green" "red"))) - " " - (propertize hostname 'face 'mode-line-buffer-id) - " " - (propertize (oni:shorten-dir dir) 'face 'font-lock-string-face) - " " - (when (not (string= branch "")) - (propertize - ;; Cut off "* " and "\n" - (substring branch 2 -1) - 'face 'font-lock-function-name-face)) - " \n> "))) + "> "))) (defun raise-eshell () "Start or switch back to `eshell'. @@ -543,7 +528,7 @@ MODE1 is enabled and vice-versa." (stante-after em-prompt (setq eshell-highlight-prompt nil) (setq eshell-prompt-function 'oni-eshell-prompt) - (setq eshell-prompt-regexp "^> ")) + (setq eshell-prompt-regexp "^[+-]> ")) (stante-after em-term (add-to-list 'eshell-visual-commands "unison")) @@ -1394,6 +1379,23 @@ If no direction is given, don't split." (stante-after esh-mode (add-to-list 'eshell-output-filter-functions #'oni:eshell-handle-url)) +(defun oni:current-dir-in-buffer-name () + (let ((branch + (shell-command-to-string + "git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))) + (rename-buffer + (setq eshell-buffer-name + (format "%s%s:%s" system-name + (if (not (string= branch "")) + (format "(%s)" (substring branch 2 -1)) + "") + (oni:shorten-dir + (abbreviate-file-name (eshell/pwd)))))))) + +(stante-after em-dirs + (add-hook 'eshell-directory-change-hook + #'oni:current-dir-in-buffer-name)) + (provide 'init) ;;; init.el ends here -- cgit v1.2.3-54-g00ecf