diff --git a/oni-eshell.el b/oni-eshell.el index 71f1e31..16585db 100644 --- a/oni-eshell.el +++ b/oni-eshell.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2020.1106.164034 +;; Version: 2020.1210.213125 ;; Package-Requires: (eshell-fringe-status esh-autosuggest xterm-color eshell-syntax-highlighting) ;; This program is free software; you can redistribute it and/or modify @@ -81,6 +81,24 @@ (eshell/cd (file-name-directory (buffer-file-name (get-buffer buffer-name)))) (eshell-reset)) +(defun oni-eshell-shorten-directories (path) + "Shorten PATH to a list of unique shortened directory names." + (let* ((directories (split-string path "/" t)) + (new-path + (string-join + (mapcar (lambda (d) + (let ((name (substring d 0 1)) + (length 1)) + (while (cl-find-if (lambda (s) (and (not (string= s d)) + (string-prefix-p name s))) + directories) + (setq name (substring d 0 (cl-incf length)))) + name)) + directories) "/"))) + (if (string-prefix-p "~" new-path) + new-path + (concat "/" new-path)))) + (add-hook 'eshell-before-prompt-hook #'oni-eshell--set-xterm-variables) (add-hook 'eshell-first-time-mode-hook #'oni-eshell--expand-keymap) (add-hook 'eshell-load-hook #'oni-eshell--disable-ansi-color-handling)