Skip to content

Instantly share code, notes, and snippets.

@tkych
Last active December 14, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkych/5004008 to your computer and use it in GitHub Desktop.
Save tkych/5004008 to your computer and use it in GitHub Desktop.
minimum prompt for eshell
;;;; Last modified : 2013-02-21 20:11:37 tkych
;;====================================================================
;; Minimum Prompt for Eshell
;;====================================================================
;; Only when working-directory or user-name is changed, displays it.
;; Note:
;; If more than 2 eshells are opened and switched them,
;; working-directory may be displayed without changing working-directory.
(setq eshell-prompt-function
(lexical-let ((prev-user-at "")
(prev-pwd ""))
(lambda ()
(lexical-let ((curr-user-at (concat (user-login-name)
"@" (system-name)))
(curr-pwd (abbreviate-file-name (eshell/pwd))))
(concat
(if (string= prev-user-at curr-user-at)
(if (string= prev-pwd curr-pwd)
""
(concat "[" (setq prev-pwd curr-pwd) "]\n"))
(concat "["
(setq prev-user-at curr-user-at)
":"
(setq prev-pwd curr-pwd)
"]\n"))
(if (= (user-uid) 0) "# " "$ "))))))
(setq eshell-prompt-regexp "^[^#$]*[#$] ")
;; c.f. http://qiita.com/items/c195d7c64e30c28577fa
;; by acple, avoid 'text is read-only'
(defadvice eshell-get-old-input (after eshell-read-only-korosu activate)
(setq ad-return-value (substring-no-properties ad-return-value)))
;;====================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment