branch: master
commit 66d9956caf158ec00622f1f6f4405d7459598911
Author: nathan moreau <[email protected]>
Commit: nathan moreau <[email protected]>
Add an action to kill all buffers from a worktree.
---
counsel.el | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/counsel.el b/counsel.el
index fb91842..403eb3a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1449,6 +1449,19 @@ TREE is the selected candidate."
(and (string-match-p "Not a git repository" out) (error "Not a git
repository!"))
out))
+(defun counsel-git-close-worktree-files-action (root-dir)
+ "Close all buffers from the worktree located at ROOT-DIR."
+ (save-excursion
+ (dolist (buf (buffer-list))
+ (set-buffer buf)
+ (and buffer-file-name
+ (string= "." (file-relative-name root-dir (counsel-git-toplevel)))
+ (kill-buffer buf)))))
+
+(ivy-set-actions
+ 'counsel-git-change-worktree
+ '(("k" counsel-git-close-worktree-files-action "kill all")))
+
;;;###autoload
(defun counsel-git-change-worktree ()
"Find the file corresponding to the current buffer on a different worktree."