Skip to content

Instantly share code, notes, and snippets.

@dwcoates
Created December 14, 2017 05:39
Show Gist options
  • Select an option

  • Save dwcoates/0b0153046ae52a262d1a82cb7a46c3c5 to your computer and use it in GitHub Desktop.

Select an option

Save dwcoates/0b0153046ae52a262d1a82cb7a46c3c5 to your computer and use it in GitHub Desktop.
Swap between minimal/cwd+git eshell prompts.
(defun eshell-default-prompt-function ()
(interactive)
(concat
(system-name) ":"
(propertize (car (last (split-string (pwd-repl-home (eshell/pwd)) "/"))) 'face
`(:foreground "#cdcd00"))
(or (curr-dir-git-branch-string (eshell/pwd)))
(propertize "# " 'face 'default)))
(defun eshell-short-prompt-function ()
(interactive)
(concat (format-time-string "#" (current-time))
(if (= (user-uid) 0) " # " " ")))
(defun eshell-swap-prompt ()
(interactive)
(setq eshell-prompt-function
(if (eq eshell-prompt-function
'eshell-default-prompt-function)
'eshell-short-prompt-function
'eshell-default-prompt-function))
(eshell-send-input))
(add-hook 'eshell-mode-hook
(lambda () (define-key eshell-mode-map (kbd "C-c C-;")
'eshell-swap-prompt)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment