summaryrefslogtreecommitdiff
path: root/eshell-conf.el
diff options
context:
space:
mode:
Diffstat (limited to 'eshell-conf.el')
-rw-r--r--eshell-conf.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/eshell-conf.el b/eshell-conf.el
index 1d0871f..866d4bf 100644
--- a/eshell-conf.el
+++ b/eshell-conf.el
@@ -377,6 +377,26 @@ candidates."
If called without ARGS, then use ./ instead."
(eshell/ls "-hal" (or args "./")))
+;;; Group directories first in `eshell/ls'
+
+(defun durand-eshell-group-entries-by-directory (entries)
+ "Sort ENTRIES so that directories come before non-directories."
+ (sort entries
+ (lambda (l r)
+ (cond
+ ((string= (car l) "."))
+ ((string= (car r) ".") nil)
+ ((string= (car l) ".."))
+ ((string= (car r) "..") nil)
+ ((and (file-directory-p (car l))
+ (file-directory-p (car r)))
+ (string-lessp (car l) (car r)))
+ ((file-directory-p (car l)))
+ ((file-directory-p (car r)) nil)))))
+
+(advice-add #'eshell-ls-sort-entries
+ :after #'durand-eshell-group-entries-by-directory)
+
;;; Integration with Tramp
(add-to-list 'eshell-modules-list 'eshell-tramp)