diff options
Diffstat (limited to 'lisp/init-dired.el')
-rw-r--r-- | lisp/init-dired.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/init-dired.el b/lisp/init-dired.el index ca5bb5c..0e5b2cf 100644 --- a/lisp/init-dired.el +++ b/lisp/init-dired.el @@ -28,6 +28,25 @@ (setq dired-guess-shell-alist-user '(("\\.pdf\\'" "zathura"))) +(defun km/dired-copy-project-filename-as-kill () + "Copy names of marked project files into kill ring. +This is similar to `dired-copy-filename-as-kill', but the leading +path is always relative to `projectile-project-root'." + (interactive) + (let* ((project-dir (projectile-project-root)) + (string + (mapconcat 'identity + (--map (file-relative-name it project-dir) + (dired-get-marked-files t)) + " "))) + (if (eq last-command 'kill-region) + (kill-append string nil) + (kill-new string)) + (message "%s" string))) + +(after 'projectile + (define-key dired-mode-map "W" 'km/dired-copy-project-filename-as-kill)) + (defun km/dired-switch-to-buffer () (interactive) (let ((buffer-name (km/dired-completing-buffer))) |