Last active
December 14, 2015 01:09
-
-
Save tkych/5004008 to your computer and use it in GitHub Desktop.
minimum prompt for eshell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; 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