From 256982e335a3feebc4c2b54090647c4dc0947048 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Mon, 20 May 2024 00:31:41 +0300 Subject: [PATCH] readme: add filter mode --- README.org | 13 +++++++++++++ eshell-atuin.el | 13 +++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index 4f8b0d4..de8b1b8 100644 --- a/README.org +++ b/README.org @@ -60,6 +60,19 @@ Enable =eshell-atuin-mode= to turn on storing eshell commands in =atuin=. Run =eshell-atuin-history= inside an =eshell= buffer to browse the saved history. Accepting the completion will insert the command. +** Filter mode +=atuin= supports 4 [[https://docs.atuin.sh/configuration/config/#filter_mode][filter modes]]: global (default), host, session, directory. Default filter mode for =eshell-atuin= can be set as follows: + +#+begin_src emacs-lisp +(setq eshell-atuin-filter-mode 'global) +#+end_src + +In order to switch the mode at runtime, run =M-x eshell-atuin-history= with the prefix argument: +- =C-u 0 M-x eshell-atuin-history= for =global= +- =C-u 1 M-x eshell-atuin-history= for =host= +- =C-u 2 M-x eshell-atuin-history= for =session= +- =C-u 3 M-x eshell-atuin-history= for =directory= + * Implementation notes I may have overengineered the package a bit to scale on lots of records. diff --git a/eshell-atuin.el b/eshell-atuin.el index 168f669..fb08e36 100644 --- a/eshell-atuin.el +++ b/eshell-atuin.el @@ -132,10 +132,15 @@ include here. Some examples: :group 'eshell-atuin :type '(choice (const nil :tag "Use default filter") - (const 'global :tag "All hosts, all sessions, all directories") - (const 'host :tag "History just from this host") - (const 'session :tag "History just from this session") - (const 'directory :tag "History just from this directory"))) + (const global :tag "All hosts, all sessions, all directories") + (const host :tag "History just from this host") + (const session :tag "History just from this session") + (const directory :tag "History just from this directory")) + :set + (lambda (sym value) + (set-default sym value) + (when (fboundp #'eshell-atuin--history-rotate-cache) + (eshell-atuin--history-rotate-cache)))) (defvar-local eshell-atuin--history-id nil "Atuin ID of the current eshell command.")