mirror of
https://gitlab.com/vindarel/ciel.git
synced 2026-01-18 23:31:07 -08:00
scripts: add finder.lisp
This commit is contained in:
parent
2cb5ce9bb4
commit
dc2c40d4fd
2 changed files with 38 additions and 1 deletions
38
src/scripts/finder.lisp
Normal file
38
src/scripts/finder.lisp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env ciel
|
||||
|
||||
;;
|
||||
;; $ ciel finder.lisp foo bar | xargs mpv
|
||||
;;
|
||||
;; Searches for files matching "foo" and "bar" (in any order) in my music directories.
|
||||
;;
|
||||
;; o/
|
||||
;;
|
||||
|
||||
(in-package :ciel-user)
|
||||
|
||||
(defparameter *directories* '("~/Music/" "~/Downloads/"))
|
||||
|
||||
(defun find-on-directory (root params)
|
||||
(fof:finder*
|
||||
:root root
|
||||
:predicates (apply #'fof/p:every-path~ params)))
|
||||
|
||||
(defun find-files (&optional params)
|
||||
(unless params
|
||||
(format *error-output* "No search terms supplied.~&Usage: finder.lisp search terms.~&")
|
||||
(return-from find-files))
|
||||
(let ((str:*ignore-case* t)
|
||||
(params (ensure-list params)))
|
||||
(flatten
|
||||
(loop for root in *directories*
|
||||
collect
|
||||
(find-on-directory root params)))))
|
||||
|
||||
(defun pprint-for-shell (list)
|
||||
(mapcar (lambda (p)
|
||||
(format t "~s~&" (fof:path p)))
|
||||
list)
|
||||
(terpri))
|
||||
|
||||
#+ciel
|
||||
(pprint-for-shell (find-files (rest *script-args*)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue