Jump to content

Tab completion for terminal commands


Recommended Posts

I do not think it’s currently doable, no (at least not well). Tab completion is a shell feature, not a terminal feature, and Alfred doesn’t even read your shell’s startup files (a common mistake you’ll find on the forums is users not being able to run a certain command because it’s somewhere in their PATH, and you need to explicitly tell Alfred that). It seems to also not even care about your input until you actually do something with it, the exception being script filters in workflows, which means it could maybe kind of work in this context, but its unlikely it’d result in a good implementation/experience.

Link to comment
  • 2 years later...

It could be faked, i.e. Alfred keeps its own list of executables on your PATH (much as it does with applications) and recognises and autocompletes paths in the query.
 
Talking to your actual shell is an entirely different ballgame, mostly because you'd probably need a full terminal emulator for it to work properly. There's an app called D-Term that does this already (basically a Finder add-on that gives you a query box connected to your shell, with autocomplete etc.
 
It is much slower than Alfred, however. This is mostly due to the startup time of the shell—Homebrew in particular can really slow down your shell if you're calling $(brew --prefix)
 

Edited by deanishe
Link to comment

Yes, when I mention the limitations I’m always thinking of full shell emulation, mainly because that’s what I believe people are asking about. I say that in the sense that if we had the faked auto-completion, we’d then have people asking instead about why it didn’t work in their specific case, the same way we have people asking why Alfred isn’t reading their PATH in workflows. Those are few and far between, now, but you likely remember (and I think you even explained it a number times) how that question used to pop up.

On the other hand, perhaps some auto-completion would indeed be better than none. Admittedly, when answering these types of questions I always have in the back of my head “is this more difficult to implement than it is nice to have?” because with Alfred’s team being so small, every feature being worked on now pushes the others farther down the line by no trivial amount. 

Regarding the last point, is $(brew --prefix) slow for you? It’s pretty fast for me. The only thing that’s annoyingly slow on my startup is sourcing nvm (for which there are numerous reports on their issue tracker).

Also, on another note, though it shouldn’t make a difference speed-wise, use $(brew --repository) instead.

Link to comment

Yes, when I mention the limitations I’m always thinking of full shell emulation, mainly because that’s what I believe people are asking about.

They may not think they are, but they probably are. Give 'em program/file completion, and then it'll be "why don't my aliases work?"

I'd like to see smarter (fuzzy) filesystem navigation, like fzf (or CtrlP or other similar vim plugins). Navigating the filesystem is alway such a chore in Alfred compared to vim.

 

But I'd agree that almost any other completion isn't a priority.

 

Regarding the last point, is $(brew --prefix) slow for you? It’s pretty fast for me. The only thing that’s annoyingly slow on my startup is sourcing nvm (for which there are numerous reports on their issue tracker).

 

Relatively speaking, brew is very slow. It takes about a second to source all my includes. My benchmarks show that's 95% brew and pyenv (nvm's Python port).

 

Homebrew is the main culprit. It executes a lot faster than pyenv, but it gets called by loads of oh-my-zsh plugins to get different prefixes.

Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...