/shrink-path.el

It's a fork of https://gitlab.com/bennya/shrink-path.el

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

shrink-path.el

Small utility functions that allow for fish-style trunctated directories in eshell and for example modeline.

Screenshots

https://gitlab.com/bennya/shrink-path.el/raw/screenshots/eshell-prompt.png https://gitlab.com/bennya/shrink-path.el/raw/screenshots/doom-modeline.png

Installation

shrink-path is available via MELPA (and MELPA Stable).

It can be installed by using M-x package-install RET shrink-path RET inside Emacs or even better using use-package.

(use-package shrink-path
  :ensure t
  :demand t)

Example configuration

eshell

Configuration soon to be found in DOOM Emacs.

(setq eshell-prompt-regexp "^.* λ "
      eshell-prompt-function #'+eshell/prompt)

(defun +eshell/prompt ()
  (let ((base/dir (shrink-path-prompt default-directory)))
        (concat (propertize (car base/dir)
                            'face 'font-lock-comment-face)
                (propertize (cdr base/dir)
                            'face 'font-lock-constant-face)
                (propertize (+eshell--current-git-branch)
                            'face 'font-lock-function-name-face)
                (propertize " λ" 'face 'eshell-prompt-face)
                ;; needed for the input text to not have prompt face
                (propertize " " 'face 'default))))

;; for completeness sake
(defun +eshell--current-git-branch ()
    (let ((branch (car (loop for match in (split-string (shell-command-to-string "git branch") "\n")
                             when (string-match "^\*" match)
                             collect match))))
      (if (not (eq branch nil))
          (concat " [" (substring branch 2) "]")
        "")))