Eshell prompt
This commit is contained in:
parent
534b8ccba3
commit
41ac1061ff
@ -14,18 +14,48 @@ This is taken from a website that I can't remember at the moment."
|
|||||||
#'find-file-other-window
|
#'find-file-other-window
|
||||||
(mapcar
|
(mapcar
|
||||||
#'expand-file-name (eshell-flatten-list (reverse args))))))
|
#'expand-file-name (eshell-flatten-list (reverse args))))))
|
||||||
|
|
||||||
(defun eshell/clear ()
|
(defun eshell/clear ()
|
||||||
"Clear the scrollback buffer, like `clear' in a real shell..."
|
"Clear the scrollback buffer, like `clear' in a real shell..."
|
||||||
(eshell/clear-scrollback))
|
(eshell/clear-scrollback))
|
||||||
|
|
||||||
(defun eshell/faketty (&rest args)
|
(defun eshell/faketty (&rest args)
|
||||||
"USAGE: `faketty ARGS` where ARGS is anything that spews colors.
|
"USAGE: `faketty ARGS` where ARGS is anything that spews colors.
|
||||||
Credit: https://stackoverflow.com/questions/1401002/how-to-trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe"
|
Credit: https://stackoverflow.com/questions/1401002/how-to-trick-an-application-into-thinking-its-stdout-is-a-terminal-not-a-pipe"
|
||||||
(let
|
(shell-command-to-string
|
||||||
((shell-command-dont-erase-buffer t))
|
(format "script -qfc %s /dev/null" args)))
|
||||||
(shell-command
|
|
||||||
(concat "script -qfc '" args "' /dev/null")
|
(defun with-face (str &rest face-plist)
|
||||||
(current-buffer))
|
(propertize str 'face face-plist))
|
||||||
))
|
(defun custom-eshell-prompt ()
|
||||||
|
(let* (
|
||||||
|
;; Get the git branch.
|
||||||
|
(git-branch-unparsed
|
||||||
|
(shell-command-to-string "git rev-parse --abbrev-ref HEAD 2>/dev/null"))
|
||||||
|
(git-branch
|
||||||
|
(if (string= git-branch-unparsed "")
|
||||||
|
""
|
||||||
|
;; Remove the trailing newline.
|
||||||
|
(substring git-branch-unparsed 0 -1)))
|
||||||
|
)
|
||||||
|
(concat
|
||||||
|
;; Timestamp.
|
||||||
|
;; (with-face
|
||||||
|
;; (format-time-string "[%a, %b %d | %H:%M:%S]\n" (current-time))
|
||||||
|
;; :inherit font-lock-builtin-face)
|
||||||
|
;; Directory.
|
||||||
|
(with-face (concat (airline-shorten-directory default-directory (/ (window-width) 2)) " ") :inherit font-lock-constant-face)
|
||||||
|
;; Git branch.
|
||||||
|
(unless (string= git-branch "")
|
||||||
|
(with-face (concat "[" git-branch "]") :inherit font-lock-string-face))
|
||||||
|
"\n"
|
||||||
|
;; Prompt.
|
||||||
|
;; NOTE: Need to keep " $" for the next/previous prompt regexp to work.
|
||||||
|
(with-face ">" :inherit font-lock-preprocessor-face)
|
||||||
|
" "
|
||||||
|
)))
|
||||||
|
(setq eshell-prompt-function 'custom-eshell-prompt)
|
||||||
|
(setq eshell-highlight-prompt nil)
|
||||||
|
|
||||||
(provide 'eshell-settings)
|
(provide 'eshell-settings)
|
||||||
;;; eshell-settings.el ends here
|
;;; eshell-settings.el ends here
|
||||||
|
@ -286,7 +286,7 @@
|
|||||||
:custom
|
:custom
|
||||||
(airline-cursor-colors nil)
|
(airline-cursor-colors nil)
|
||||||
(airline-display-directory t)
|
(airline-display-directory t)
|
||||||
(airline-eshell-colors t)
|
(airline-eshell-colors nil)
|
||||||
(airline-shortened-directory-length 20)
|
(airline-shortened-directory-length 20)
|
||||||
(airline-utf-glyph-separator-left 9585)
|
(airline-utf-glyph-separator-left 9585)
|
||||||
(airline-utf-glyph-separator-right 9586)
|
(airline-utf-glyph-separator-right 9586)
|
||||||
|
Loading…
Reference in New Issue
Block a user