Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eshell source #13

Open
minad opened this issue Jan 20, 2022 · 3 comments
Open

Add eshell source #13

minad opened this issue Jan 20, 2022 · 3 comments

Comments

@minad
Copy link
Contributor

minad commented Jan 20, 2022

Hi Karthik,

I tried to improve my eshell experience a little bit yesterday. What about including the eshell directory source from your post by default?

(defvar eshell-last-dir-ring)
(declare-function ring-elements "ring")
(defvar consult-dir--source-eshell
  (list :name "Eshell"
        :narrow ?e
        :category 'file
        :face 'consult-file
        :enabled
        (lambda ()
          (and (bound-and-true-p eshell-last-dir-ring)
               (not (ring-empty-p eshell-last-dir-ring))))
        :items
        (lambda ()
          (delete-dups
           (mapcar #'abbreviate-file-name
                   (ring-elements eshell-last-dir-ring))))))

Furthermore if the buffer is an eshell buffer, the selected directory could be passed directly to cd? Or do you think it is better to use consult-dir-default-command in that case, set buffer-locally in the eshell?

(setq-local consult-dir-default-command
            (lambda ()
              (interactive)
              (insert "cd " (eshell-escape-arg default-directory))
              (eshell-send-input)))
@minad
Copy link
Contributor Author

minad commented Jan 20, 2022

I just saw that @oantolin already proposed this a while ago on reddit: https://www.reddit.com/r/emacs/comments/q4as4c/jumping_directories_in_eshell/

@karthink
Copy link
Owner

karthink commented Feb 5, 2022

@minad Sorry for the delay. This would be useful to folks who use both Eshell and consult-dir, which includes you, me and @oantolin. But I'm guessing most consult-dir users don't use Eshell, since both packages are quite niche. Do you think it makes sense to add an eshell-specific feature to consult-dir from a composability perspective?

@oantolin
Copy link

oantolin commented Feb 6, 2022

You may be right that eshell is a little niche, but you can editorialize: encourage your users to use it by providing the source. I think any package that comes with Emacs is fair game for that. (Although, some really are too obscure: I have commands to add or remove email addresses from ecomplete's adressbook, but I wouldn't add them to Embark because ecomplete is practically unknown.)

A good compromise is too add the source to consult-dir but not have it on by default, consider that option too. Also, does shell also track directories? Maybe the source can be expanded to include directories from both, which makes it useful for more people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants