Case Duckworth 2021-05-28 20:47:58 -05:00
parent a712b76ae9
commit 8fd98de300
1 changed files with 39 additions and 1 deletions

40
init.el
View File

@ -314,7 +314,45 @@
(define-key eshell-mode-map (kbd "C-d")
#'eshell-quit-or-delete-char)
(when (boundp 'simple-modeline--mode-line)
(setq mode-line-format '(:eval simple-modeline--mode-line))))))
(setq mode-line-format '(:eval simple-modeline--mode-line)))))
(with-eval-after-load 'eshell
;; Record arguments
(defvar my-eshell-arg-history nil)
(defvar my-eshell-arg-history-index nil)
(add-to-list 'savehist-additional-variables 'my-eshell-arg-history)
(defun my-eshell-record-args (&rest _)
"Record unique arguments onto the front of `my-eshell-arg-history'."
(setq my-eshell-arg-history
(cl-loop with history = my-eshell-arg-history
for arg in (reverse eshell-last-arguments)
do (setq history (cons arg (remove arg history)))
finally return history)))
(defun my-eshell-insert-prev-arg ()
"Insert an argument from `my-eshell-arg-history' at point."
(interactive)
(if (eq last-command 'my-eshell-insert-prev-arg)
(progn
(let ((pos (point)))
(eshell-backward-argument 1)
(delete-region (point) pos))
(if-let ((text (nth my-eshell-arg-history-index
my-eshell-arg-history)))
(progn
(insert text)
(cl-incf my-eshell-arg-history-index))
(insert (cl-first my-eshell-arg-history))
(setq my-eshell-arg-history-index 1)))
(insert (cl-first my-eshell-arg-history))
(setq my-eshell-arg-history-index 1)))
(add-hook 'eshell-mode-hook
(lambda ()
(add-hook 'eshell-post-command-hook
#'my-eshell-record-args nil t)
(local-set-key (kbd "M-.") #'my-eshell-insert-prev-arg)))))
(setup eww
(:option eww-search-prefix "https://duckduckgo.com/html?q="