summaryrefslogtreecommitdiffstats
path: root/.emacs.d/init.el
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-12-29 23:36:16 +0100
committerGravatar Tom Willemse2013-12-29 23:36:16 +0100
commit13b91519fe2e639cb8fea572cf6df597e838023b (patch)
tree06ff97ff6207706f057ebd549eb8d606c28ead83 /.emacs.d/init.el
parent6c7fbd2d9d2eb6daa8adeeef4229c9ace20ef7b1 (diff)
downloademacs-13b91519fe2e639cb8fea572cf6df597e838023b.tar.gz
emacs-13b91519fe2e639cb8fea572cf6df597e838023b.zip
Use buffer-name for some information in eshell
This makes the eshell prompt shorter
Diffstat (limited to '.emacs.d/init.el')
-rw-r--r--.emacs.d/init.el38
1 files changed, 20 insertions, 18 deletions
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