diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 0589b8f2..d8a01429 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -1154,6 +1154,7 @@ Sets environment variables by starting a shell (imalison:named-compile "glide up")) (defhydra imalison:compile nil "Compile" + ("s" helm-command-from-zsh "Select a command from shell history") ("c" imalison:named-compile "Enter Custom Command") ("t" imalison:make-test "Test") ("u" imalison:glide-up "Update Dependencies")))) @@ -1662,39 +1663,6 @@ I use helm for almost all emacs completion (projectile-all-project-files)))) :candidate-number-limit 99999 :buffer "*helm org inbuffer*")) - ;; helm zsh source history - (defvar helm-c-source-zsh-history - '((name . "Zsh History") - (candidates . helm-c-zsh-history-set-candidates) - (action . (("Execute Command" . helm-c-zsh-history-action))) - (volatile) - (requires-pattern . 3) - (delayed))) - - (defun helm-c-zsh-history-set-candidates (&optional request-prefix) - (let ((pattern (replace-regexp-in-string - " " ".*" - (or (and request-prefix - (concat request-prefix - " " helm-pattern)) - helm-pattern)))) - (with-current-buffer (find-file-noselect "~/.zsh_history" t t) - (auto-revert-mode -1) - (goto-char (point-max)) - (loop for pos = (re-search-backward pattern nil t) - while pos - collect (replace-regexp-in-string - "\\`:.+?;" "" - (buffer-substring (line-beginning-position) - (line-end-position))))))) - - (defun helm-c-zsh-history-action (candidate) - (async-shell-command candidate)) - - (defun helm-command-from-zsh () - (interactive) - (require 'helm) - (helm-other-buffer 'helm-c-source-zsh-history "*helm zsh history*")) (use-package helm-descbinds :demand t @@ -1821,6 +1789,42 @@ I use helm for almost all emacs completion (use-package jump-char :bind (("C-;" . jump-char-forward))) #+END_SRC +**** helm-zsh-history +This was stolen from https://github.com/jwiegley/dot-emacs +#+BEGIN_SRC emacs-lisp + (defvar helm-c-source-zsh-history + '((name . "Zsh History") + (candidates . helm-c-zsh-history-set-candidates) + (action . (("Execute Command" . helm-c-zsh-history-action))) + (volatile) + (requires-pattern . 3) + (delayed))) + + (defun helm-c-zsh-history-set-candidates (&optional request-prefix) + (let ((pattern (replace-regexp-in-string + " " ".*" + (or (and request-prefix + (concat request-prefix + " " helm-pattern)) + helm-pattern)))) + (with-current-buffer (find-file-noselect "~/.zsh_history" t t) + (auto-revert-mode -1) + (goto-char (point-max)) + (loop for pos = (re-search-backward pattern nil t) + while pos + collect (replace-regexp-in-string + "\\`:.+?;" "" + (buffer-substring (line-beginning-position) + (line-end-position))))))) + + (defun helm-c-zsh-history-action (candidate) + (imalison:named-compile candidate)) + + (defun helm-command-from-zsh () + (interactive) + (require 'helm) + (helm-other-buffer 'helm-c-source-zsh-history "*helm zsh history*")) +#+END_SRC ** Text Manipulation *** smartparens #+BEGIN_SRC emacs-lisp