about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--emacs.d/init-eshell.el66
-rw-r--r--emacs.d/init-settings.el1
-rw-r--r--emacs.d/init.el1
3 files changed, 68 insertions, 0 deletions
diff --git a/emacs.d/init-eshell.el b/emacs.d/init-eshell.el
new file mode 100644
index 000000000000..858715737a2e
--- /dev/null
+++ b/emacs.d/init-eshell.el
@@ -0,0 +1,66 @@
+;; EShell configuration
+
+(defvar home-dir)
+(setq home-dir (expand-file-name "~"))
+
+(setq eshell-path-env (concat
+		       "/usr/local/bin:"
+		       (concat home-dir "/bin:")
+		       eshell-path-env))
+
+;; Prompt configuration
+
+(defun clean-pwd (path)
+  "Turns a path of the form /foo/bar/baz into /f/b/baz
+   (inspired by fish shell)"
+  (message path)
+  (let* ((current-dir (split-string path "/"))
+	 (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))))
+
+(setq eshell-pwd-convert-function
+      (lambda  (path)
+	(clean-pwd (replace-regexp-in-string
+		    home-dir
+		    "~"
+		    path))))
+
+(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
+   (with-face (concat (eshell/pwd) " ") :foreground  "#96a6c8")
+   (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)
+
+;; EShell functions that come in handy
+
+;; clear in eshell
+(defun eshell/clear ()
+  "clear the eshell buffer."
+  (interactive)
+  (let ((inhibit-read-only t))
+    (erase-buffer)))
diff --git a/emacs.d/init-settings.el b/emacs.d/init-settings.el
index b4ad1c20955c..2d1f3c4bcc98 100644
--- a/emacs.d/init-settings.el
+++ b/emacs.d/init-settings.el
@@ -6,6 +6,7 @@
 ;;; Code:
 
 (add-to-list 'exec-path "/usr/local/bin")
+(add-to-list 'exec-path (expand-file-name "~/bin"))
 (add-to-list 'exec-path "/Applications/Racket/bin")
 
 (when window-system
diff --git a/emacs.d/init.el b/emacs.d/init.el
index 9d4ac4b72036..9c3304fdc796 100644
--- a/emacs.d/init.el
+++ b/emacs.d/init.el
@@ -30,6 +30,7 @@
 		  rainbow-delimiters
                   geiser
                   quack
+		  rainbow-mode
 		  )
 
   "A list of packages to install at launch.")