chiark / gitweb /
el/dot-emacs.el: Twiddle `eshell' settings.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 21 Oct 2010 13:52:06 +0000 (14:52 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 21 Oct 2010 14:00:00 +0000 (15:00 +0100)
  * Abbreviate the prompt, if possible.

  * Turn the aliases into real functions.  Seems slightly prettier.

el/dot-emacs.el

index 525d2d419aef8b11c738ea591dfde4db8556346b..c51803b7a1308e397ee69d99a2520fa19c516ac4 100644 (file)
@@ -2135,13 +2135,21 @@ (defun mdw-eshell-prompt ()
            (save-match-data
              (replace-regexp-in-string "\\..*$" "" (system-name)))
            " "
-           (eshell/pwd)
+           (let* ((pwd (eshell/pwd)) (npwd (length pwd))
+                  (home (expand-file-name "~")) (nhome (length home)))
+             (if (and (>= npwd nhome)
+                      (or (= nhome npwd)
+                          (= (elt pwd nhome) ?/)
+                      (string= (substring pwd 0 nhome) home)))
+                 (concat "~" (substring pwd (length home)))
+               pwd))
            right)))
 (setq eshell-prompt-function 'mdw-eshell-prompt)
 (setq eshell-prompt-regexp "^\\[[^]>]+\\(\\]\\|>>?\\)")
 
-(defalias 'eshell/e 'find-file)
-(defalias 'eshell/w3m 'w3m-goto-url)
+(defun eshell/e (file) (find-file file) nil)
+(defun eshell/ee (file) (find-file-other-window file) nil)
+(defun eshell/w3m (url) (w3m-goto-url url) nil)
 
 (mdw-define-face eshell-prompt (t :weight bold))
 (mdw-define-face eshell-ls-archive (t :weight bold :foreground "red"))