Last active
February 22, 2023 01:45
-
-
Save aserranoni/cd671a989061f88195c39d7c913ff29c to your computer and use it in GitHub Desktop.
Homemade emacs-lisp functions to search bash history and copy commands to the clipboard
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 characters
(defun ariel/get-file-lines (filename) | |
(with-temp-buffer (insert-file-contents filename) | |
(cl-remove-duplicates (split-string (buffer-string) "\n" t))) | |
) | |
(defun ariel/copy-string-to-clipboard (str) | |
(with-temp-buffer (insert str) | |
(clipboard-kill-region (point-min) (point-max)))) | |
(defun ariel/get-command-from-bash-history () | |
(interactive) | |
(let* ( | |
(strs (ariel/get-file-lines "~/.bash_history")) | |
) | |
(ivy-read "Bash History: " strs :action (lambda (x) (ariel/copy-string-to-clipboard x))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment