Skip to content

Instantly share code, notes, and snippets.

@thierryvolpiatto
Last active October 16, 2022 05:56
Show Gist options
  • Save thierryvolpiatto/a0e1121cd9340ac9fcf86865e974c019 to your computer and use it in GitHub Desktop.
Save thierryvolpiatto/a0e1121cd9340ac9fcf86865e974c019 to your computer and use it in GitHub Desktop.
; $Id: helm-ls.el,v 1.4 2018/01/22 21:39:56 thierry Exp $
(defvar helm-source-ls
(helm-build-async-source "ls"
:candidates-process (lambda ()
(let* ((basedir (if (file-directory-p helm-pattern)
helm-pattern
(helm-basedir helm-pattern)))
(proc
(start-file-process "hls" nil "ls"
"-al" "-h" "--color=always"
basedir)))
;; (set-process-sentinel proc (lambda (process event) nil))
(helm-attrset 'basedir basedir)
proc))
:filtered-candidate-transformer (list 'helm-ff-sort-candidates
(lambda (candidates _source)
(cl-loop for c in (cdr candidates)
for disp = (ansi-color-apply c)
for fn = (expand-file-name
(car (last (split-string disp)))
(helm-attr 'basedir))
when (or (member (helm-basename fn) '("." ".."))
(string-match
(helm--mapconcat-pattern helm-pattern) fn))
collect (cons disp fn))))
:persistent-action-if 'helm-find-files-persistent-action-if
:persistent-help "Hit1 Expand Candidate, Hit2 or (C-u) Find file"
:action-transformer 'helm-find-files-action-transformer
:keymap helm-find-files-map
:action 'helm-find-files-actions))
(add-to-list 'helm--file-completion-sources "ls")
(defun helm-ls ()
(interactive)
(helm :sources 'helm-source-ls
:buffer "*helm ls*"
:input default-directory
:candidate-number-limit 9999))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment