[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 142306e 069/272: counsel.el (counsel-git-stash): New comma

From: Oleh Krehel
Subject: [elpa] master 142306e 069/272: counsel.el (counsel-git-stash): New command
Date: Mon, 25 Apr 2016 10:13:17 +0000

branch: master
commit 142306edf985e1e641fba08dd00c0cfed70d7760
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-git-stash): New command
    * counsel.el (counsel-git-stash-kill-action): New defun.
    Fixes #374
 counsel.el |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/counsel.el b/counsel.el
index d80b5fb..2a6a264 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1522,6 +1522,24 @@ An extra action allows to switch to the process buffer."
               ("o" counsel-list-processes-action-delete "kill")
               ("s" counsel-list-processes-action-switch "switch"))))
+(defun counsel-git-stash-kill-action (x)
+  (when (string-match "\\([^:]+\\):" x)
+    (kill-new (message (format "git stash apply %s" (match-string 1 x))))))
+(defun counsel-git-stash ()
+  "Search through all available git stashes."
+  (interactive)
+  (let ((dir (locate-dominating-file default-directory ".git")))
+    (if (null dir)
+        (error "Not in a git repository")
+      (let ((cands (split-string (shell-command-to-string
+                                  "IFS=$'\n'
+for i in `git stash list --format=\"%gd\"`; do
+    git stash show -p $i | grep -H --label=\"$i\" \"$1\"
+done") "\n" t)))
+        (ivy-read "git stash: " cands
+                  :action 'counsel-git-stash-kill-action)))))
 (provide 'counsel)
 ;;; counsel.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]