yarn icon indicating copy to clipboard operation
yarn copied to clipboard

CLI auto completion

Open octref opened this issue 9 years ago • 22 comments

Something npm has always bugged me is auto completion.

It requires putting source <(npm completion) to my zshrc, which is extremely slow and seldom outputs useful completion.

A few examples yarn could do:

letting yarn <Tab> outputs all commands:

install -- install package
remove  -- remove package
...other commands

letting each flag output useful information: yarn install -<Tab>

-g -- install package globally
-S -- install package and save as dependency

letting yarn install <Tab> prompt a list of cached packages: yarn install r<Tab>

[email protected]
[email protected]

letting yarn rm <Tab> list packages installed locally yarn rm r<Tab>

[email protected]
[email protected]

Thanks for the good work!

octref avatar Oct 11 '16 15:10 octref

Hi I came here to suggest an auto-completion feature for yarn. Saw this so thought I'd comment here to flag my interest. Yarn like npm has a lot of commands and I often use npm's auto-completion. Would help people switching to yarn.

mikelnrd avatar Nov 23 '16 12:11 mikelnrd

There is yarn-completions

There is also a completion-plugin for oh-my-zsh.

cjk avatar Jan 26 '17 09:01 cjk

@cjk How does that even work?

I installed yarn-completions - didn't work. Realized it's actually some kind of plugin for tabtab, so I installed that. Still doesn't work. Re-sourced my bash profile. Still doesn't work. Is there really more configuration required?

It'd be really nice to have this functionality included in yarn itself.

Matmo10 avatar Feb 06 '17 18:02 Matmo10

@cjk yarn-completions works great, thanks for the suggestion!

It would be very useful to include that plugin into Yarn itself

Ionaru avatar Feb 08 '17 14:02 Ionaru

@Matmo10 did you ever get completions working?

wavded avatar Apr 14 '17 19:04 wavded

@wavded Yep (https://github.com/mklabs/yarn-completions/issues/8)

Matmo10 avatar Apr 14 '17 19:04 Matmo10

Didn't see @Matmo10's comment unfortunately.

I spent the day today writing a pretty feature-complete bash completion, including computed autocomplete for scripts, local and global package names, and more.

If anybody is still in the market for it, you can find it here. https://github.com/dsifford/yarn-completion

Maintainer: If this is something you'd like for me to PR into this project directly, I'd be glad to do that as well.

Thanks 👍

dsifford avatar Apr 16 '17 02:04 dsifford

Didn't see @Matmo10's comment unfortunately.

I'm thankful for that, because your solution is much better :+1:

pesho avatar Apr 16 '17 02:04 pesho

@pesho Thanks! Glad to hear you like it 😄

dsifford avatar Apr 16 '17 02:04 dsifford

FYI: just pushed an update which makes the completions feature-complete up to yarn v0.24.4 https://github.com/dsifford/yarn-completion/releases/tag/v0.3.0

dsifford avatar May 12 '17 18:05 dsifford

For zsh users, the zsh-completions package (installable via brew) also has Yarn completions: https://github.com/zsh-users/zsh-completions/blob/6a2895b7f5832f006f602271aee102df46d6c965/src/_yarn

OliverJAsh avatar Sep 21 '17 12:09 OliverJAsh

Please make developers happier! Include completions developed by @dsifford to official package. Npm has command npm completion many years.

evgenymarkov avatar Dec 16 '17 08:12 evgenymarkov

Yes please do.

ninrod avatar May 28 '18 20:05 ninrod

Maintainers: This issue is labeled "needs discussion". Is it possible to provide direction on what needs to be discussed for this to become a first-class feature of yarn? Or is the required discussion regarding whether it should be part of yarn? Thanks!

SpainTrain avatar Oct 31 '18 19:10 SpainTrain

Yes, I would love to discuss this a bit more... or get it implemented. I don't understand why it is missing

danielo515 avatar Jan 30 '19 17:01 danielo515

Any update on the status of this?

lararosekelley avatar Feb 25 '19 01:02 lararosekelley

Is any of the suggestions above working good for zsh? Seemed to be bash specific…?

I still lean on npm to just help me with my own scripts in package.json. Hate to have cat package.json just to remind myself all the time…

~/d/p/kb-frontend ❯❯❯ npm run   [tab hit]                                                           ⏎ master ✭
backend                clean                  deploy-master-to-prod  undo-rolluot
build                  db                     dev

hedefalk avatar Jul 09 '19 16:07 hedefalk

@hedefalk https://github.com/zsh-users/zsh-completions/blob/master/src/_yarn

dsifford avatar Jul 10 '19 18:07 dsifford

Guys any update on this? Any way to integrate autocomplete inside yarn?

sdc224 avatar Jul 07 '20 08:07 sdc224

I found a workaround:

npm-cli-completions

:sweat_smile:

vhscom avatar Jan 05 '22 10:01 vhscom

guys we can close this finally, every one has moved to pnpm since yarn is a dead project.

airtonix avatar Feb 14 '23 10:02 airtonix

There is another alternative which I've been using a few years - https://github.com/romainberger/yarn-completion

Install globally and add bash file to somewhere like bash_completions and adjust the instructions as required.

If you run into yarn-complete: command not found then follow my instruction on https://github.com/romainberger/yarn-completion/issues/1

One other minor bug is it doesn't work well with scripts with a : in it, such as lint:fix or build:ios/build/android etc This problem is outlined in https://github.com/romainberger/yarn-completion/issues/2

ChromeQ avatar Aug 08 '24 01:08 ChromeQ