Add function to eshell config that shortens directory names
This function isn't being used yet.
This commit is contained in:
parent
0f22bb9729
commit
0b7c98baf1
1 changed files with 19 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue