Created
January 29, 2016 07:24
-
-
Save heikkil/177ff4c4b8a02d574958 to your computer and use it in GitHub Desktop.
Revisions
-
heikkil created this gist
Jan 29, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ ;; mod from http://blog.binchen.org/posts/use-ivy-mode-to-search-bash-history.html (require 'dash) (defun counsel-yank-fish-history () "Yank the fish history" (interactive) (let (hist-cmd collection val) (shell-command "history -r") ; reload history (setq collection (nreverse (split-string (with-temp-buffer (insert-file-contents (file-truename "~/.config/fish/fish_history")) (buffer-string)) "\n" t))) (setq collection (--keep (replace-regexp-in-string "- cmd: " "" it) (--filter (string-match "^- cmd:" it) collection))) (when (and collection (> (length collection) 0) (setq val (if (= 1 (length collection)) (car collection) (ivy-read (format "Fish history:") collection)))) (kill-new val) (message "%s => kill-ring" val))))