I'm using the tool fasd to access frequently used directories and files faster without providing the full path. If I use the fasd command directly, I get beautifully auto-completion of its results while I type. It would be awesome if I could get these candidates as another group in the completion menu when using cd for directories and files for an editor like vim or similar commands.
Currently I have a mapping that I need to trigger manually. It calls fzf with the list of currently available results by fasd for the current input text. I then filter the results in fzf, select and entry, get back to the command line and then continue.
Could be improved...
This plugin is awesome. So is fasd. Hope to get them combined on a new level. :wink:
The way fasd handles completions is really funky and not according to standards with the latest versions of Zsh. In addition, fasd has not seen any maintenance or updates since 2015. I highly recommend switching to another another similar tool that is more actively maintained, such as zoxide.
Hmm okay. Thanks for the insight!
So I just took a quick look onto zoxide. It appears to me like I would use this as a cd replacement with a global alias (like exa for ls or bat for cat/less). And then I would get the completion automatically because of the commands nature. Right?
@weilbith Alright, a first prototype of zoxide-based completion for cd and autocd is now available in the dev branch. Please check it out. 馃檪
Okay I'm slightly confused. Assume (very likely) I now decide to switch from fasd to zoxide as you recommend. Do I now need to use the z command to change directories so can become trained and build up its database and scores? So I understand that the next time I use cd you provide me now with the z candidates. But does z also learn my directories while using cd? The GIF in the README looks different, that's why I'm asking. So to me it appears (also by their writing) that I should exchange cd with z. So I would theoretically get the auto-completion automatically (yeah double automated). Don't I?
I'm just looking again at fasd now and it does seem to have more features than zoxide. So, zoxide is not a straight-up replacement for fasd. Pity that it's not being maintained.
But also, now that I look at at again, I should be able to integrate to fasd or any other similar tool, too, in very much the same way.
In either case, whether you use fasd, zoxide or whatever else, you do not need aliases or most of the other stuff those tools install. All you need is to install their hook that records the present working dir whenever you change dir. After that, I can query the tool when doing directory completions to offer you whatever it suggests, in addition to the local directories.
That sounds like you would need to do this manually for the specific tools?
Yes, because I cannot query the tool if I don't know how to query it. 馃檪
But doing so is fairly simple once I know what the correct command is.
fasd dir completion support is now available on the dev branch. Please try it out. 馃檪
But do you still think it is good to introduce it to your plugin? :thinking:
I mean the issue is basically that these completions should be tight to another command as they come from (cd in this case). Is there maybe another solution to do this in a more generic way and don't clutter your plugin?
I tried it. It only shows me always one result. While when I use my old approach I can see more for the same typed text.
But do you still think it is good to introduce it to your plugin? 馃
I mean the issue is basically that these completions should be tight to another command as they come from (cd in this case). Is there maybe another solution to do this in a more generic way and don't clutter your plugin?
I think it's fine. I've already added code that makes zsh-autocomplete play nice with fzf, zsh-autosuggestions and syntax highlighting plugins. It's not much effort to add this. 馃檪
I tried it. It only shows me always one result. While when I use my old approach I can see more for the same typed text.
Yes, I know. This was just a quick prototype. More will follow. 馃檪
Yes, I know. This was just a quick prototype. More will follow.
Haha I wasn't aware. Then it works like expected :D
@weilbith I pushed in a new version of the feature on the dev branch. Try it out.
That looks pretty solid.
Observation: I also get file suggestions, even I use cd and the completion group is called frequent or recent directory (should be maybe plural ^^).
I also get file suggestions, even I use
cd
That can be fixed.
and the completion group is called
frequent or recent directory(should be maybe plural ^^).
In Zsh, completion group names are always singular.
@weilbith I pushed in another update on the dev branch. Please try it out.
Not sure what you exactly added. So here are my observations:
cat does also get directory suggestions and no file suggestionsAnyways already really good work. I would be also fine with just the fdirectories. :)
- for the change directory command I get directories only
- using a command that expects a file as parameter like
catdoes also get directory suggestions and no file suggestions
Yes, that's exactly what I've implemented so far. 馃檪
I will add fasd-based file completion soon. It's pretty straight-forward.
@weilbith The dev branch now also includes fasd completion for files. Please test.
Yep seem to work. Thanks! :blush:
Now merged to master.