コマンドの実行履歴をanythingで選んでコピーする。
呼び出した後に、C-SPCで幾つかmarkしておいて"kill-new (marked canidates)"を選ぶと複数行を一気にコピーできて便利です。
code
(defun anything-select-from-zsh-history () (interactive) (let1 source '((name . "zsh history") (init . (lambda () (let1 buf (anything-candidate-buffer 'global) (with-current-buffer buf (erase-buffer)) (set-process-sentinel (start-process-shell-command "cat" buf "cat ~/.zsh_history | cut -d ';' -f 2") (lambda (&rest args) nil))))) (candidates-in-buffer) (search-from-end) (action . (("kill-new" . kill-new) ("kill-new (marked candidates)" . (lambda (_) (let1 seq (nreverse (anything-marked-candidates)) (kill-new (mapconcat 'identity seq "\n")))))))) (anything (list source))))