Skip to content

Commit

Permalink
eshell-atuin: support TRAMP host filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
SqrtMinusOne committed May 19, 2024
1 parent 256982e commit 952e663
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions eshell-atuin.el
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ results of the command in `eshell-atuin--post-exec'."
(when-let ((input (eshell-atuin--get-input)))
(setq eshell-atuin--history-id
(with-temp-buffer
(with-environment-variables (("ATUIN_SESSION" eshell-atuin--session-id))
(with-environment-variables (("ATUIN_SESSION" eshell-atuin--session-id)
("ATUIN_HOST_NAME"
(or (file-remote-p default-directory 'host)
(system-name))) )
(let ((ret (call-process
eshell-atuin-executable nil t nil
"history" "start" "--" input)))
Expand Down Expand Up @@ -211,7 +214,10 @@ of the command."
;; work here.
(proc (with-environment-variables
(("ATUIN_LOG" "error")
("ATUIN_SESSION" eshell-atuin--session-id))
("ATUIN_SESSION" eshell-atuin--session-id)
("ATUIN_HOST_NAME"
(or (file-remote-p default-directory 'host)
(system-name))))
(start-process-shell-command "atuin-history-stop" buf
(string-join proc-args " ")))))
(set-process-sentinel
Expand Down Expand Up @@ -318,7 +324,8 @@ This is used to speed up the lookup after `competing-read' in

(defun eshell-atuin--history-cache-p (filter-mode)
"Return non-nil if atuin search with FILTER-MODE has to be cached."
(memq filter-mode '(nil global host session)))
(or (memq filter-mode '(nil global session))
(and (eq filter-mode 'host) (null (file-remote-p default-directory 'host)))))

(defun eshell-atuin--history-rotate-cache ()
"Rotate `eshell-atuin' history cache by filter mode.
Expand Down Expand Up @@ -425,7 +432,9 @@ See `eshell-atuin--history-cache' on algorithm."
(symbol-name eshell-atuin-filter-mode)))
,@eshell-atuin-search-options))
(ret (with-environment-variables
(("ATUIN_SESSION" eshell-atuin--session-id))
(("ATUIN_SESSION" eshell-atuin--session-id)
("ATUIN_HOST_NAME" (or (file-remote-p default-directory 'host)
(system-name))))
(apply #'call-process eshell-atuin-executable
nil t nil proc-args))))
(unless (or (= 0 ret) (= 1 ret))
Expand Down

0 comments on commit 952e663

Please sign in to comment.