Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Search fish history using ivy mode
;; mod from
(require 'dash)
(defun counsel-yank-fish-history ()
"Yank the fish history"
(let (hist-cmd collection val)
(shell-command "history -r") ; reload history
(setq collection
(split-string (with-temp-buffer (insert-file-contents (file-truename "~/.config/fish/fish_history"))
(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))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment