diff options
Diffstat (limited to 'emacs.org')
-rwxr-xr-x | emacs.org | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -318,16 +318,31 @@ Generate a random password between 20 and 40 characters * Dired ** Functions #+begin_src emacs-lisp + (require 'dired) + (defun dired-watch-video () + "Watch play file with mpv." (interactive) (call-process-shell-command (format "mpv \"%s\"" (dired-get-filename)) nil 0)) (defun dired-set-wallpaper () - "Set NAME as wallpaper." - (interactive) - (call-process-shell-command - (format "feh --bg-scale %s" (dired-get-filename) nil 0))) + "Set NAME as wallpaper using feh." + (interactive) + (call-process-shell-command + (format "feh --bg-scale %s" (dired-get-filename)) nil 0)) + + (defun delete-files-except () + "Delete all files inside directory except match." + (interactive) + (let* ((directory (read-directory-name "Select directory: ")) + (files (directory-files directory t)) + (except-match (read-string "Except the ones that have: "))) + (dolist (file files) + (unless (or (string= "." (substring file -1)) + (string= ".." (substring file -2)) + (string-match except-match file) + (dired-delete-file file t)))))) #+end_src ** Keybindings #+begin_src emacs-lisp |