diff options
author | Tom Willemse | 2020-12-10 21:30:37 -0800 |
---|---|---|
committer | Tom Willemse | 2020-12-10 21:31:33 -0800 |
commit | 0b7c98baf1572458088c431e20d201a421ee042f (patch) | |
tree | 339f22518f69150b3cdd308c3a845d557d8499e3 /oni-eshell.el | |
parent | 0f22bb9729868e190bb716166c544c5d76147f85 (diff) | |
download | emacs-config-0b7c98baf1572458088c431e20d201a421ee042f.tar.gz emacs-config-0b7c98baf1572458088c431e20d201a421ee042f.zip |
Add function to eshell config that shortens directory names
This function isn't being used yet.
Diffstat (limited to 'oni-eshell.el')
-rw-r--r-- | oni-eshell.el | 20 |
1 files changed, 19 insertions, 1 deletions
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 <tom@ryuslash.org> ;; 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) |